diff options
| author | Alex Valavanis <valavanisalex@gmail.com> | 2011-12-22 16:14:02 +0000 |
|---|---|---|
| committer | Alex Valavanis <valavanisalex@gmail.com> | 2011-12-22 16:14:02 +0000 |
| commit | ed9b50d93f24dd949d910f049991d8bfddc6d8d8 (patch) | |
| tree | 3a5599ea3d510a6c47c5ab9463c1e1ef53e5287a /src/libgdl | |
| parent | GDL: rebase on upstream commit 012C4 (2010-05-02) (diff) | |
| download | inkscape-ed9b50d93f24dd949d910f049991d8bfddc6d8d8.tar.gz inkscape-ed9b50d93f24dd949d910f049991d8bfddc6d8d8.zip | |
GDL: Rebase on upstream commit 871CA (2010-06-26)
(bzr r10794)
Diffstat (limited to 'src/libgdl')
| -rw-r--r-- | src/libgdl/gdl-dock-bar.c | 795 | ||||
| -rw-r--r-- | src/libgdl/gdl-dock-item-button-image.c | 13 | ||||
| -rw-r--r-- | src/libgdl/gdl-dock-item-grip.c | 162 | ||||
| -rw-r--r-- | src/libgdl/gdl-dock-item.c | 194 | ||||
| -rw-r--r-- | src/libgdl/gdl-dock-master.c | 25 | ||||
| -rw-r--r-- | src/libgdl/gdl-dock-notebook.c | 21 | ||||
| -rw-r--r-- | src/libgdl/gdl-dock-object.c | 54 | ||||
| -rw-r--r-- | src/libgdl/gdl-dock-paned.c | 92 | ||||
| -rw-r--r-- | src/libgdl/gdl-dock-placeholder.c | 23 | ||||
| -rw-r--r-- | src/libgdl/gdl-dock-tablabel.c | 101 | ||||
| -rw-r--r-- | src/libgdl/gdl-dock.c | 109 | ||||
| -rw-r--r-- | src/libgdl/gdl-switcher.c | 64 | ||||
| -rw-r--r-- | src/libgdl/gdl-tools.h | 187 | ||||
| -rw-r--r-- | src/libgdl/gdl.h | 1 |
14 files changed, 861 insertions, 980 deletions
diff --git a/src/libgdl/gdl-dock-bar.c b/src/libgdl/gdl-dock-bar.c index 663378b7f..84a901308 100644 --- a/src/libgdl/gdl-dock-bar.c +++ b/src/libgdl/gdl-dock-bar.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * This file is part of the GNOME Devtools Libraries. * @@ -27,7 +27,6 @@ #include <stdlib.h> #include <string.h> -#include "gdl-tools.h" #include "gdl-dock.h" #include "gdl-dock-master.h" #include "gdl-dock-bar.h" @@ -42,7 +41,6 @@ enum { /* ----- Private prototypes ----- */ static void gdl_dock_bar_class_init (GdlDockBarClass *klass); -static void gdl_dock_bar_instance_init (GdlDockBar *dockbar); static void gdl_dock_bar_get_property (GObject *object, guint prop_id, @@ -71,7 +69,7 @@ struct _GdlDockBarPrivate { /* ----- Private functions ----- */ -GDL_CLASS_BOILERPLATE (GdlDockBar, gdl_dock_bar, GtkBox, GTK_TYPE_BOX) +G_DEFINE_TYPE (GdlDockBar, gdl_dock_bar, GTK_TYPE_BOX) static void gdl_dock_bar_size_request (GtkWidget *widget, GtkRequisition *requisition ); @@ -124,7 +122,7 @@ gdl_dock_bar_class_init (GdlDockBarClass *klass) } static void -gdl_dock_bar_instance_init (GdlDockBar *dockbar) +gdl_dock_bar_init (GdlDockBar *dockbar) { dockbar->_priv = g_new0 (GdlDockBarPrivate, 1); dockbar->_priv->master = NULL; @@ -209,7 +207,7 @@ gdl_dock_bar_destroy (GtkObject *object) g_free (priv); } - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_bar_parent_class)->destroy (object); } static void @@ -463,464 +461,479 @@ static void gdl_dock_bar_size_allocate (GtkWidget *widget, } static void gdl_dock_bar_size_vrequest (GtkWidget *widget, - GtkRequisition *requisition ) + GtkRequisition *requisition ) { - GtkBox *box; - GtkBoxChild *child; - GtkRequisition child_requisition; - GList *children; - gint nvis_children; - gint height; - - box = GTK_BOX (widget); - requisition->width = 0; - requisition->height = 0; - nvis_children = 0; - - children = box->children; - while (children) + GtkBox *box; + GtkBoxChild *child; + GtkRequisition child_requisition; + GList *children; + gint nvis_children; + gint height; + guint border_width; + + box = GTK_BOX (widget); + requisition->width = 0; + requisition->height = 0; + nvis_children = 0; + + children = gtk_container_get_children (GTK_CONTAINER (box)); + while (children) { - child = children->data; - children = children->next; - - if (gtk_widget_get_visible (child->widget)) - { - gtk_widget_size_request (child->widget, &child_requisition); - - if (box->homogeneous) - { - height = child_requisition.height + child->padding * 2; - requisition->height = MAX (requisition->height, height); - } - else - { - requisition->height += child_requisition.height + child->padding * 2; - } - - requisition->width = MAX (requisition->width, child_requisition.width); - - nvis_children += 1; - } + child = children->data; + children = children->next; + + if (gtk_widget_get_visible (child->widget)) + { + gtk_widget_size_request (child->widget, &child_requisition); + + if (gtk_box_get_homogeneous (box)) + { + height = child_requisition.height + child->padding * 2; + requisition->height = MAX (requisition->height, height); + } + else + { + requisition->height += child_requisition.height + child->padding * 2; + } + + requisition->width = MAX (requisition->width, child_requisition.width); + + nvis_children += 1; + } } - if (nvis_children > 0) + if (nvis_children > 0) { - if (box->homogeneous) - requisition->height *= nvis_children; - requisition->height += (nvis_children - 1) * box->spacing; + if (gtk_box_get_homogeneous (box)) + requisition->height *= nvis_children; + requisition->height += (nvis_children - 1) * gtk_box_get_spacing (box); } - requisition->width += GTK_CONTAINER (box)->border_width * 2; - requisition->height += GTK_CONTAINER (box)->border_width * 2; + border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); + requisition->width += border_width * 2; + requisition->height += border_width * 2; } static void gdl_dock_bar_size_vallocate (GtkWidget *widget, - GtkAllocation *allocation) + GtkAllocation *allocation) { - GtkBox *box; - GtkBoxChild *child; - GList *children; - GtkAllocation child_allocation; - gint nvis_children; - gint nexpand_children; - gint child_height; - gint height; - gint extra; - gint y; - - box = GTK_BOX (widget); - widget->allocation = *allocation; - - nvis_children = 0; - nexpand_children = 0; - children = box->children; - - while (children) + GtkBox *box; + GtkBoxChild *child; + GList *children; + GtkAllocation child_allocation; + gint nvis_children; + gint nexpand_children; + gint child_height; + gint height; + gint extra; + gint y; + guint border_width; + GtkRequisition requisition; + + box = GTK_BOX (widget); + gtk_widget_set_allocation (widget, allocation); + + gtk_widget_get_requisition (widget, &requisition); + + nvis_children = 0; + nexpand_children = 0; + children = gtk_container_get_children (GTK_CONTAINER (box)); + + while (children) { - child = children->data; - children = children->next; - - if (gtk_widget_get_visible (child->widget)) - { - nvis_children += 1; - if (child->expand) - nexpand_children += 1; - } + child = children->data; + children = children->next; + + if (gtk_widget_get_visible (child->widget)) + { + nvis_children += 1; + if (child->expand) + nexpand_children += 1; + } } - if (nvis_children > 0) + border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); + + if (nvis_children > 0) { - if (box->homogeneous) - { - height = (allocation->height - - GTK_CONTAINER (box)->border_width * 2 - - (nvis_children - 1) * box->spacing); - extra = height / nvis_children; - } - else if (nexpand_children > 0) - { - height = (gint) allocation->height - (gint) widget->requisition.height; - extra = height / nexpand_children; - } - else - { - height = 0; - extra = 0; - } - - y = allocation->y + GTK_CONTAINER (box)->border_width; - child_allocation.x = allocation->x + GTK_CONTAINER (box)->border_width; - child_allocation.width = MAX (1, (gint) allocation->width - (gint) GTK_CONTAINER (box)->border_width * 2); - - children = box->children; - while (children) - { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget)) - { - if (box->homogeneous) - { - if (nvis_children == 1) - child_height = height; - else - child_height = extra; - - nvis_children -= 1; - height -= extra; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (child->widget, &child_requisition); - child_height = child_requisition.height + child->padding * 2; - - if (child->expand) - { - if (nexpand_children == 1) - child_height += height; - else - child_height += extra; - - nexpand_children -= 1; - height -= extra; - } - } - - if (child->fill) - { - child_allocation.height = MAX (1, child_height - (gint)child->padding * 2); - child_allocation.y = y + child->padding; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (child->widget, &child_requisition); - child_allocation.height = child_requisition.height; - child_allocation.y = y + (child_height - child_allocation.height) / 2; - } - - gtk_widget_size_allocate (child->widget, &child_allocation); - - y += child_height + box->spacing; - } - } - - y = allocation->y + allocation->height - GTK_CONTAINER (box)->border_width; - - children = box->children; - while (children) - { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_END) && gtk_widget_get_visible (child->widget)) - { - GtkRequisition child_requisition; - gtk_widget_get_child_requisition (child->widget, &child_requisition); - - if (box->homogeneous) + if (gtk_box_get_homogeneous (box)) + { + height = (allocation->height - + border_width * 2 - + (nvis_children - 1) * gtk_box_get_spacing (box)); + extra = height / nvis_children; + } + else if (nexpand_children > 0) + { + height = (gint) allocation->height - (gint) requisition.height; + extra = height / nexpand_children; + } + else + { + height = 0; + extra = 0; + } + + y = allocation->y + border_width; + child_allocation.x = allocation->x + border_width; + child_allocation.width = MAX (1, (gint) allocation->width - (gint) border_width * 2); + + children = gtk_container_get_children (GTK_CONTAINER (box)); + while (children) + { + child = children->data; + children = children->next; + + if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget)) + { + if (gtk_box_get_homogeneous (box)) { - if (nvis_children == 1) - child_height = height; - else - child_height = extra; + if (nvis_children == 1) + child_height = height; + else + child_height = extra; - nvis_children -= 1; - height -= extra; + nvis_children -= 1; + height -= extra; } - else + else { - child_height = child_requisition.height + child->padding * 2; + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + child_height = child_requisition.height + child->padding * 2; - if (child->expand) + if (child->expand) { - if (nexpand_children == 1) - child_height += height; - else - child_height += extra; + if (nexpand_children == 1) + child_height += height; + else + child_height += extra; - nexpand_children -= 1; - height -= extra; + nexpand_children -= 1; + height -= extra; } } - if (child->fill) + if (child->fill) { - child_allocation.height = MAX (1, child_height - (gint)child->padding * 2); - child_allocation.y = y + child->padding - child_height; + child_allocation.height = MAX (1, child_height - (gint)child->padding * 2); + child_allocation.y = y + child->padding; } - else + else { - child_allocation.height = child_requisition.height; - child_allocation.y = y + (child_height - child_allocation.height) / 2 - child_height; + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + child_allocation.height = child_requisition.height; + child_allocation.y = y + (child_height - child_allocation.height) / 2; } - gtk_widget_size_allocate (child->widget, &child_allocation); + gtk_widget_size_allocate (child->widget, &child_allocation); + + y += child_height + gtk_box_get_spacing (box); + } + } - y -= (child_height + box->spacing); - } - } + y = allocation->y + allocation->height - border_width; + + children = gtk_container_get_children (GTK_CONTAINER (box)); + while (children) + { + child = children->data; + children = children->next; + + if ((child->pack == GTK_PACK_END) && gtk_widget_get_visible (child->widget)) + { + GtkRequisition child_requisition; + gtk_widget_get_child_requisition (child->widget, &child_requisition); + + if (gtk_box_get_homogeneous (box)) + { + if (nvis_children == 1) + child_height = height; + else + child_height = extra; + + nvis_children -= 1; + height -= extra; + } + else + { + child_height = child_requisition.height + child->padding * 2; + + if (child->expand) + { + if (nexpand_children == 1) + child_height += height; + else + child_height += extra; + + nexpand_children -= 1; + height -= extra; + } + } + + if (child->fill) + { + child_allocation.height = MAX (1, child_height - (gint)child->padding * 2); + child_allocation.y = y + child->padding - child_height; + } + else + { + child_allocation.height = child_requisition.height; + child_allocation.y = y + (child_height - child_allocation.height) / 2 - child_height; + } + + gtk_widget_size_allocate (child->widget, &child_allocation); + + y -= (child_height + gtk_box_get_spacing (box)); + } + } } } static void gdl_dock_bar_size_hrequest (GtkWidget *widget, - GtkRequisition *requisition ) + GtkRequisition *requisition ) { - GtkBox *box; - GtkBoxChild *child; - GList *children; - gint nvis_children; - gint width; - - box = GTK_BOX (widget); - requisition->width = 0; - requisition->height = 0; - nvis_children = 0; - - children = box->children; - while (children) + GtkBox *box; + GtkBoxChild *child; + GList *children; + gint nvis_children; + gint width; + guint border_width; + + box = GTK_BOX (widget); + requisition->width = 0; + requisition->height = 0; + nvis_children = 0; + + children = gtk_container_get_children (GTK_CONTAINER (box)); + while (children) { - child = children->data; - children = children->next; + child = children->data; + children = children->next; - if (gtk_widget_get_visible (child->widget)) - { - GtkRequisition child_requisition; + if (gtk_widget_get_visible (child->widget)) + { + GtkRequisition child_requisition; - gtk_widget_size_request (child->widget, &child_requisition); + gtk_widget_size_request (child->widget, &child_requisition); - if (box->homogeneous) - { - width = child_requisition.width + child->padding * 2; - requisition->width = MAX (requisition->width, width); - } - else - { - requisition->width += child_requisition.width + child->padding * 2; - } + if (gtk_box_get_homogeneous (box)) + { + width = child_requisition.width + child->padding * 2; + requisition->width = MAX (requisition->width, width); + } + else + { + requisition->width += child_requisition.width + child->padding * 2; + } - requisition->height = MAX (requisition->height, child_requisition.height); + requisition->height = MAX (requisition->height, child_requisition.height); - nvis_children += 1; - } + nvis_children += 1; + } } - if (nvis_children > 0) + if (nvis_children > 0) { - if (box->homogeneous) - requisition->width *= nvis_children; - requisition->width += (nvis_children - 1) * box->spacing; + if (gtk_box_get_homogeneous (box)) + requisition->width *= nvis_children; + requisition->width += (nvis_children - 1) * gtk_box_get_spacing (box); } - requisition->width += GTK_CONTAINER (box)->border_width * 2; - requisition->height += GTK_CONTAINER (box)->border_width * 2; + border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); + requisition->width += border_width * 2; + requisition->height += border_width * 2; } static void gdl_dock_bar_size_hallocate (GtkWidget *widget, - GtkAllocation *allocation) + GtkAllocation *allocation) { - GtkBox *box; - GtkBoxChild *child; - GList *children; - GtkAllocation child_allocation; - gint nvis_children; - gint nexpand_children; - gint child_width; - gint width; - gint extra; - gint x; - GtkTextDirection direction; - - box = GTK_BOX (widget); - widget->allocation = *allocation; - - direction = gtk_widget_get_direction (widget); - - nvis_children = 0; - nexpand_children = 0; - children = box->children; - - while (children) + GtkBox *box; + GtkBoxChild *child; + GList *children; + GtkAllocation child_allocation; + gint nvis_children; + gint nexpand_children; + gint child_width; + gint width; + gint extra; + gint x; + guint border_width; + GtkTextDirection direction; + GtkRequisition requisition; + + box = GTK_BOX (widget); + gtk_widget_set_allocation (widget, allocation); + gtk_widget_get_requisition (widget, &requisition); + + direction = gtk_widget_get_direction (widget); + + nvis_children = 0; + nexpand_children = 0; + children = gtk_container_get_children (GTK_CONTAINER (box)); + + while (children) { - child = children->data; - children = children->next; - - if (gtk_widget_get_visible (child->widget)) - { - nvis_children += 1; - if (child->expand) - nexpand_children += 1; - } + child = children->data; + children = children->next; + + if (gtk_widget_get_visible (child->widget)) + { + nvis_children += 1; + if (child->expand) + nexpand_children += 1; + } } - if (nvis_children > 0) + border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); + + if (nvis_children > 0) { - if (box->homogeneous) - { - width = (allocation->width - - GTK_CONTAINER (box)->border_width * 2 - - (nvis_children - 1) * box->spacing); - extra = width / nvis_children; - } - else if (nexpand_children > 0) - { - width = (gint) allocation->width - (gint) widget->requisition.width; - extra = width / nexpand_children; - } - else - { - width = 0; - extra = 0; - } - - x = allocation->x + GTK_CONTAINER (box)->border_width; - child_allocation.y = allocation->y + GTK_CONTAINER (box)->border_width; - child_allocation.height = MAX (1, (gint) allocation->height - (gint) GTK_CONTAINER (box)->border_width * 2); - - children = box->children; - while (children) - { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget)) - { - if (box->homogeneous) - { - if (nvis_children == 1) - child_width = width; - else - child_width = extra; - - nvis_children -= 1; - width -= extra; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (child->widget, &child_requisition); - - child_width = child_requisition.width + child->padding * 2; - - if (child->expand) - { - if (nexpand_children == 1) - child_width += width; - else - child_width += extra; - - nexpand_children -= 1; - width -= extra; - } - } - - if (child->fill) - { - child_allocation.width = MAX (1, (gint) child_width - (gint) child->padding * 2); - child_allocation.x = x + child->padding; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (child->widget, &child_requisition); - child_allocation.width = child_requisition.width; - child_allocation.x = x + (child_width - child_allocation.width) / 2; - } - - if (direction == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; - - gtk_widget_size_allocate (child->widget, &child_allocation); - - x += child_width + box->spacing; - } - } - - x = allocation->x + allocation->width - GTK_CONTAINER (box)->border_width; - - children = box->children; - while (children) - { - child = children->data; - children = children->next; - - if ((child->pack == GTK_PACK_END) && gtk_widget_get_visible (child->widget)) - { - GtkRequisition child_requisition; - gtk_widget_get_child_requisition (child->widget, &child_requisition); - - if (box->homogeneous) + if (gtk_box_get_homogeneous (box)) + { + width = (allocation->width - + border_width * 2 - + (nvis_children - 1) * gtk_box_get_spacing (box)); + extra = width / nvis_children; + } + else if (nexpand_children > 0) + { + width = (gint) allocation->width - (gint) requisition.width; + extra = width / nexpand_children; + } + else + { + width = 0; + extra = 0; + } + + x = allocation->x + border_width; + child_allocation.y = allocation->y + border_width; + child_allocation.height = MAX (1, (gint) allocation->height - (gint) border_width * 2); + + children = gtk_container_get_children (GTK_CONTAINER (box)); + while (children) + { + child = children->data; + children = children->next; + + if ((child->pack == GTK_PACK_START) && gtk_widget_get_visible (child->widget)) + { + if (gtk_box_get_homogeneous (box)) { - if (nvis_children == 1) - child_width = width; - else - child_width = extra; + if (nvis_children == 1) + child_width = width; + else + child_width = extra; - nvis_children -= 1; - width -= extra; + nvis_children -= 1; + width -= extra; } - else + else { - child_width = child_requisition.width + child->padding * 2; + GtkRequisition child_requisition; - if (child->expand) + gtk_widget_get_child_requisition (child->widget, &child_requisition); + + child_width = child_requisition.width + child->padding * 2; + + if (child->expand) { - if (nexpand_children == 1) - child_width += width; - else - child_width += extra; + if (nexpand_children == 1) + child_width += width; + else + child_width += extra; - nexpand_children -= 1; - width -= extra; + nexpand_children -= 1; + width -= extra; } } - if (child->fill) + if (child->fill) { - child_allocation.width = MAX (1, (gint)child_width - (gint)child->padding * 2); - child_allocation.x = x + child->padding - child_width; + child_allocation.width = MAX (1, (gint) child_width - (gint) child->padding * 2); + child_allocation.x = x + child->padding; } - else + else { - child_allocation.width = child_requisition.width; - child_allocation.x = x + (child_width - child_allocation.width) / 2 - child_width; + GtkRequisition child_requisition; + + gtk_widget_get_child_requisition (child->widget, &child_requisition); + child_allocation.width = child_requisition.width; + child_allocation.x = x + (child_width - child_allocation.width) / 2; } - if (direction == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; + if (direction == GTK_TEXT_DIR_RTL) + child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; - gtk_widget_size_allocate (child->widget, &child_allocation); + gtk_widget_size_allocate (child->widget, &child_allocation); + + x += child_width + gtk_box_get_spacing (box); + } + } - x -= (child_width + box->spacing); - } - } + x = allocation->x + allocation->width - border_width; + + children = gtk_container_get_children (GTK_CONTAINER (box)); + while (children) + { + child = children->data; + children = children->next; + + if ((child->pack == GTK_PACK_END) && gtk_widget_get_visible (child->widget)) + { + GtkRequisition child_requisition; + gtk_widget_get_child_requisition (child->widget, &child_requisition); + + if (gtk_box_get_homogeneous (box)) + { + if (nvis_children == 1) + child_width = width; + else + child_width = extra; + + nvis_children -= 1; + width -= extra; + } + else + { + child_width = child_requisition.width + child->padding * 2; + + if (child->expand) + { + if (nexpand_children == 1) + child_width += width; + else + child_width += extra; + + nexpand_children -= 1; + width -= extra; + } + } + + if (child->fill) + { + child_allocation.width = MAX (1, (gint)child_width - (gint)child->padding * 2); + child_allocation.x = x + child->padding - child_width; + } + else + { + child_allocation.width = child_requisition.width; + child_allocation.x = x + (child_width - child_allocation.width) / 2 - child_width; + } + + if (direction == GTK_TEXT_DIR_RTL) + child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; + + gtk_widget_size_allocate (child->widget, &child_allocation); + + x -= (child_width + gtk_box_get_spacing (box)); + } + } } } diff --git a/src/libgdl/gdl-dock-item-button-image.c b/src/libgdl/gdl-dock-item-button-image.c index ce5c33ea6..da0cba274 100644 --- a/src/libgdl/gdl-dock-item-button-image.c +++ b/src/libgdl/gdl-dock-item-button-image.c @@ -23,13 +23,12 @@ #include "gdl-dock-item-button-image.h" #include <math.h> -#include "gdl-tools.h" #define ICON_SIZE 12 -GDL_CLASS_BOILERPLATE (GdlDockItemButtonImage, - gdl_dock_item_button_image, - GtkWidget, GTK_TYPE_WIDGET); +G_DEFINE_TYPE (GdlDockItemButtonImage, + gdl_dock_item_button_image, + GTK_TYPE_WIDGET); static gint gdl_dock_item_button_image_expose (GtkWidget *widget, @@ -115,10 +114,10 @@ gdl_dock_item_button_image_expose (GtkWidget *widget, } static void -gdl_dock_item_button_image_instance_init ( +gdl_dock_item_button_image_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 @@ -140,8 +139,6 @@ gdl_dock_item_button_image_class_init ( GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - widget_class->expose_event = gdl_dock_item_button_image_expose; widget_class->size_request = diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index 1272b950a..f0a90459c 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -39,7 +39,6 @@ #include "gdl-dock-item-grip.h" #include "gdl-dock-item-button-image.h" #include "gdl-switcher.h" -#include "gdl-tools.h" #define ALIGN_BORDER 5 #define DRAG_HANDLE_SIZE 10 @@ -58,8 +57,7 @@ struct _GdlDockItemGripPrivate { gboolean handle_shown; }; -GDL_CLASS_BOILERPLATE (GdlDockItemGrip, gdl_dock_item_grip, - GtkContainer, GTK_TYPE_CONTAINER); +G_DEFINE_TYPE (GdlDockItemGrip, gdl_dock_item_grip, GTK_TYPE_CONTAINER); GtkWidget* gdl_dock_item_create_label_widget(GdlDockItemGrip *grip) @@ -115,55 +113,33 @@ gdl_dock_item_grip_expose (GtkWidget *widget, GdkEventExpose *event) { GdlDockItemGrip *grip; -/*<<<<<<< HEAD */ + GtkAllocation allocation; GdkRectangle handle_area; GdkRectangle expose_area; grip = GDL_DOCK_ITEM_GRIP (widget); - - if(grip->_priv->handle_shown) { -/*======= - GdkRectangle title_area; - GdkRectangle expose_area; - GdkGC *bg_style; - gint layout_width; - gint layout_height; - gint text_x; - gint text_y; - - grip = GDL_DOCK_ITEM_GRIP (widget); - gdl_dock_item_grip_get_title_area (grip, &title_area); */ - - /* draw background, highlight it if the dock item or any of its - * descendants have focus */ -/* bg_style = (gdl_dock_item_or_child_has_focus (grip->item) ? - gtk_widget_get_style (widget)->dark_gc[widget->state] : - gtk_widget_get_style (widget)->mid_gc[widget->state]); + if(grip->_priv->handle_shown) { - gdk_draw_rectangle (GDK_DRAWABLE (widget->window), bg_style, TRUE, - 1, 0, widget->allocation.width - 1, widget->allocation.height); + gtk_widget_get_allocation (widget, &allocation); - if (grip->_priv->icon_pixbuf) { - GdkRectangle pixbuf_rect; ->>>>>>> gdl-2.26.0-with-inkscape */ - 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, @@ -173,7 +149,7 @@ gdl_dock_item_grip_expose (GtkWidget *widget, } - return GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); + return GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->expose_event (widget, event); } static void @@ -240,7 +216,7 @@ gdl_dock_item_grip_destroy (GtkObject *object) g_free (priv); } - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_item_grip_parent_class)->destroy (object); } static void @@ -291,6 +267,45 @@ gdl_dock_item_grip_close_clicked (GtkWidget *widget, gdl_dock_item_hide_item (grip->item); } +#if !GTK_CHECK_VERSION (2, 22, 0) +# define gtk_button_get_event_window(button) button->event_window +#endif // Gtk+ >= 2.22 + +static void +gdl_dock_item_grip_fix_iconify_button (GdlDockItemGrip *grip) +{ + GtkWidget *iconify_button = grip->_priv->iconify_button; + GdkWindow *window = NULL; + GdkEvent *event = NULL; + + GdkModifierType modifiers; + gint x = 0, y = 0; + + g_return_if_fail (gtk_widget_get_realized (iconify_button)); + + window = gtk_button_get_event_window (GTK_BUTTON (iconify_button)); + event = gdk_event_new (GDK_LEAVE_NOTIFY); + + g_assert (GDK_IS_WINDOW (window)); + gdk_window_get_pointer (window, &x, &y, &modifiers); + + event->crossing.window = g_object_ref (window); + event->crossing.send_event = FALSE; + event->crossing.subwindow = g_object_ref (window); + event->crossing.time = GDK_CURRENT_TIME; + event->crossing.x = x; + event->crossing.y = y; + event->crossing.x_root = event->crossing.y_root = 0; + event->crossing.mode = GDK_CROSSING_STATE_CHANGED; + event->crossing.detail = GDK_NOTIFY_NONLINEAR; + event->crossing.focus = FALSE; + event->crossing.state = modifiers; + + gtk_widget_event (iconify_button, event); + + gdk_event_free (event); +} + static void gdl_dock_item_grip_iconify_clicked (GtkWidget *widget, GdlDockItemGrip *grip) @@ -300,6 +315,9 @@ gdl_dock_item_grip_iconify_clicked (GtkWidget *widget, (void)widget; g_return_if_fail (grip->item != NULL); + /* Workaround to unhighlight the iconify button. */ + gdl_dock_item_grip_fix_iconify_button (grip); + parent = gtk_widget_get_parent (GTK_WIDGET (grip->item)); if (GDL_IS_SWITCHER (parent)) { @@ -323,14 +341,10 @@ gdl_dock_item_grip_iconify_clicked (GtkWidget *widget, { gdl_dock_item_iconify_item (grip->item); } - - /* Workaround to unhighlight the iconify button. */ - GTK_BUTTON (grip->_priv->iconify_button)->in_button = FALSE; - gtk_button_leave (GTK_BUTTON (grip->_priv->iconify_button)); } static void -gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip) +gdl_dock_item_grip_init (GdlDockItemGrip *grip) { GtkWidget *image; @@ -344,7 +358,7 @@ 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_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); @@ -361,7 +375,7 @@ 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_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); @@ -386,20 +400,23 @@ gdl_dock_item_grip_realize (GtkWidget *widget) { GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget); - GTK_WIDGET_CLASS (parent_class)->realize (widget); + GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->realize (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; @@ -410,11 +427,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); @@ -437,13 +454,13 @@ 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; } - GTK_WIDGET_CLASS (parent_class)->unrealize (widget); + GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->unrealize (widget); } static void @@ -451,7 +468,7 @@ gdl_dock_item_grip_map (GtkWidget *widget) { GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget); - GTK_WIDGET_CLASS (parent_class)->map (widget); + GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->map (widget); if (grip->title_window) gdk_window_show (grip->title_window); @@ -465,7 +482,7 @@ gdl_dock_item_grip_unmap (GtkWidget *widget) if (grip->title_window) gdk_window_hide (grip->title_window); - GTK_WIDGET_CLASS (parent_class)->unmap (widget); + GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->unmap (widget); } static void @@ -473,18 +490,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; @@ -513,19 +530,19 @@ 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); + GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->size_allocate (widget, allocation); gtk_widget_size_request (grip->_priv->close_button, &close_requisition); @@ -534,17 +551,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)) { @@ -587,7 +604,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; @@ -605,8 +622,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); } @@ -675,7 +692,6 @@ gdl_dock_item_grip_class_init (GdlDockItemGripClass *klass) GtkWidgetClass *widget_class; GtkContainerClass *container_class; - parent_class = g_type_class_peek_parent (klass); gobject_class = G_OBJECT_CLASS (klass); gtk_object_class = GTK_OBJECT_CLASS (klass); widget_class = GTK_WIDGET_CLASS (klass); diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index d9aa9eff5..50be88583 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -37,7 +37,6 @@ #include <string.h> #include <gdk/gdkkeysyms.h> -#include "gdl-tools.h" #include "gdl-dock.h" #include "gdl-dock-item.h" #include "gdl-dock-item-grip.h" @@ -54,7 +53,6 @@ /* ----- Private prototypes ----- */ static void gdl_dock_item_class_init (GdlDockItemClass *class); -static void gdl_dock_item_instance_init (GdlDockItem *item); static GObject *gdl_dock_item_constructor (GType type, guint n_construct_properties, @@ -200,7 +198,7 @@ struct _GdlDockItemPrivate { /* ----- Private functions ----- */ -GDL_CLASS_BOILERPLATE (GdlDockItem, gdl_dock_item, GdlDockObject, GDL_TYPE_DOCK_OBJECT); +G_DEFINE_TYPE (GdlDockItem, gdl_dock_item, GDL_TYPE_DOCK_OBJECT); static void add_tab_bindings (GtkBindingSet *binding_set, @@ -475,7 +473,7 @@ gdl_dock_item_class_init (GdlDockItemClass *klass) } static void -gdl_dock_item_instance_init (GdlDockItem *item) +gdl_dock_item_init (GdlDockItem *item) { gtk_widget_set_has_window (GTK_WIDGET (item), TRUE); gtk_widget_set_can_focus (GTK_WIDGET (item), TRUE); @@ -528,12 +526,9 @@ gdl_dock_item_constructor (GType type, { GObject *g_object; - g_object = GDL_CALL_PARENT_WITH_DEFAULT (G_OBJECT_CLASS, - constructor, - (type, - n_construct_properties, - construct_param), - NULL); + g_object = G_OBJECT_CLASS (gdl_dock_item_parent_class)-> constructor (type, + n_construct_properties, + construct_param); if (g_object) { GdlDockItem *item = GDL_DOCK_ITEM (g_object); GtkWidget *hbox; @@ -705,7 +700,7 @@ gdl_dock_item_destroy (GtkObject *object) g_free (priv); } - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_item_parent_class)->destroy (object); } static void @@ -806,8 +801,8 @@ gdl_dock_item_set_focus_child (GtkContainer *container, { g_return_if_fail (GDL_IS_DOCK_ITEM (container)); - if (GTK_CONTAINER_CLASS (parent_class)->set_focus_child) { - (* GTK_CONTAINER_CLASS (parent_class)->set_focus_child) (container, child); + if (GTK_CONTAINER_CLASS (gdl_dock_item_parent_class)->set_focus_child) { + (* GTK_CONTAINER_CLASS (gdl_dock_item_parent_class)->set_focus_child) (container, child); } gdl_dock_item_showhide_grip (GDL_DOCK_ITEM (container)); @@ -817,9 +812,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); @@ -863,10 +860,13 @@ 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; + //gtk_widget_size_request (widget, requisition); } static void @@ -880,31 +880,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; @@ -945,7 +947,7 @@ gdl_dock_item_map (GtkWidget *widget) 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) @@ -970,7 +972,7 @@ gdl_dock_item_unmap (GtkWidget *widget) 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); @@ -979,9 +981,11 @@ 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)); @@ -991,10 +995,11 @@ gdl_dock_item_realize (GtkWidget *widget) 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); @@ -1005,26 +1010,28 @@ 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; (void)previous_style; g_return_if_fail (widget != NULL); @@ -1033,10 +1040,12 @@ gdl_dock_item_style_set (GtkWidget *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); } } @@ -1044,8 +1053,12 @@ static void gdl_dock_item_paint (GtkWidget *widget, GdkEventExpose *event) { - gtk_paint_box (widget->style, - widget->window, + GdlDockItem *item; + + item = GDL_DOCK_ITEM (widget); + + gtk_paint_box (gtk_widget_get_style (widget), + gtk_widget_get_window (widget), gtk_widget_get_state (widget), GTK_SHADOW_NONE, &event->area, widget, @@ -1061,9 +1074,11 @@ 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)); + GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->expose_event (widget,event); } return FALSE; @@ -1088,10 +1103,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); @@ -1106,13 +1122,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; @@ -1228,10 +1246,7 @@ gdl_dock_item_key_press (GtkWidget *widget, if (event_handled) return TRUE; else - return GDL_CALL_PARENT_WITH_DEFAULT (GTK_WIDGET_CLASS, - key_press_event, - (widget, event), - FALSE); + return GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->key_press_event (widget, event); } static gboolean @@ -1240,21 +1255,21 @@ gdl_dock_item_dock_request (GdlDockObject *object, gint y, GdlDockRequest *request) { - GtkAllocation *alloc; + GtkAllocation alloc; gint rel_x, rel_y; /* 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; - rel_y = y - alloc->y; + rel_x = x - alloc.x; + rel_y = y - alloc.y; /* Location is inside. */ - if (rel_x > 0 && rel_x < alloc->width && - rel_y > 0 && rel_y < alloc->height) { + if (rel_x > 0 && rel_x < alloc.width && + rel_y > 0 && rel_y < alloc.height) { float rx, ry; GtkRequisition my, other; gint divider = -1; @@ -1264,8 +1279,8 @@ gdl_dock_item_dock_request (GdlDockObject *object, gdl_dock_item_preferred_size (GDL_DOCK_ITEM (object), &my); /* Calculate location in terms of the available space (0-100%). */ - rx = (float) rel_x / alloc->width; - ry = (float) rel_y / alloc->height; + rx = (float) rel_x / alloc.width; + ry = (float) rel_y / alloc.height; /* Determine dock location. */ if (rx < SPLIT_RATIO) { @@ -1291,8 +1306,8 @@ gdl_dock_item_dock_request (GdlDockObject *object, /* Reset rectangle coordinates to entire item. */ request->rect.x = 0; request->rect.y = 0; - request->rect.width = alloc->width; - request->rect.height = alloc->height; + request->rect.width = alloc.width; + request->rect.height = alloc.height; GdlDockItemBehavior behavior = GDL_DOCK_ITEM(object)->behavior; @@ -1339,8 +1354,8 @@ gdl_dock_item_dock_request (GdlDockObject *object, /* adjust returned coordinates so they are have the same origin as our window */ - request->rect.x += alloc->x; - request->rect.y += alloc->y; + request->rect.x += alloc.x; + request->rect.y += alloc.y; /* Set possible target location and return TRUE. */ request->target = object; @@ -1367,6 +1382,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; @@ -1381,8 +1397,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), @@ -1672,7 +1689,10 @@ gdl_dock_item_tab_button (GtkWidget *widget, GdkEventButton *event, gpointer data) { - GdlDockItem *item = GDL_DOCK_ITEM(data); + GdlDockItem *item; + GtkAllocation allocation; + + item = GDL_DOCK_ITEM(data); (void)widget; @@ -1686,8 +1706,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;*/ @@ -1934,8 +1955,8 @@ gdl_dock_item_set_orientation (GdlDockItem *item, "orientation", orientation, NULL); }; - - GDL_CALL_VIRTUAL (item, GDL_DOCK_ITEM_GET_CLASS, set_orientation, (item, orientation)); + if (GDL_DOCK_ITEM_GET_CLASS (item)->set_orientation) + GDL_DOCK_ITEM_GET_CLASS (item)->set_orientation (item, orientation); g_object_notify (G_OBJECT (item), "orientation"); } } @@ -2116,6 +2137,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)) @@ -2142,8 +2165,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, @@ -2323,13 +2347,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/src/libgdl/gdl-dock-master.c b/src/libgdl/gdl-dock-master.c index 57d0618ec..2bbb8eb3b 100644 --- a/src/libgdl/gdl-dock-master.c +++ b/src/libgdl/gdl-dock-master.c @@ -27,7 +27,6 @@ #include "gdl-i18n.h" -#include "gdl-tools.h" #include "gdl-dock-master.h" #include "gdl-dock.h" #include "gdl-dock-item.h" @@ -42,7 +41,6 @@ /* ----- Private prototypes ----- */ static void gdl_dock_master_class_init (GdlDockMasterClass *klass); -static void gdl_dock_master_instance_init (GdlDockMaster *master); static void gdl_dock_master_dispose (GObject *g_object); static void gdl_dock_master_set_property (GObject *object, @@ -128,7 +126,7 @@ static guint master_signals [LAST_SIGNAL] = { 0 }; /* ----- Private interface ----- */ -GDL_CLASS_BOILERPLATE (GdlDockMaster, gdl_dock_master, GObject, G_TYPE_OBJECT); +G_DEFINE_TYPE (GdlDockMaster, gdl_dock_master, G_TYPE_OBJECT); static void gdl_dock_master_class_init (GdlDockMasterClass *klass) @@ -189,7 +187,7 @@ gdl_dock_master_class_init (GdlDockMasterClass *klass) } static void -gdl_dock_master_instance_init (GdlDockMaster *master) +gdl_dock_master_init (GdlDockMaster *master) { master->dock_objects = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); @@ -323,7 +321,7 @@ gdl_dock_master_dispose (GObject *g_object) master->_priv = NULL; } - GDL_CALL_PARENT (G_OBJECT_CLASS, dispose, (g_object)); + G_OBJECT_CLASS (gdl_dock_master_parent_class)->dispose (g_object); } static void @@ -484,6 +482,7 @@ gdl_dock_master_drag_motion (GdlDockItem *item, GdlDockMaster *master; GdlDockRequest my_request, *request; GdkWindow *window; + GdkWindow *widget_window; gint win_x, win_y; gint x, y; GdlDock *dock = NULL; @@ -508,15 +507,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); @@ -525,9 +526,11 @@ gdl_dock_master_drag_motion (GdlDockItem *item, } if (dock) { + GdkWindow *dock_window = gtk_widget_get_window (GTK_WIDGET (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), @@ -538,10 +541,12 @@ gdl_dock_master_drag_motion (GdlDockItem *item, /* try to dock the item in all the docks in the ring in turn */ for (l = master->toplevel_docks; l; l = l->next) { + GdkWindow *dock_window; dock = GDL_DOCK (l->data); + dock_window = gtk_widget_get_window (GTK_WIDGET (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), diff --git a/src/libgdl/gdl-dock-notebook.c b/src/libgdl/gdl-dock-notebook.c index 3db3fab3f..6b6b4f755 100644 --- a/src/libgdl/gdl-dock-notebook.c +++ b/src/libgdl/gdl-dock-notebook.c @@ -26,7 +26,6 @@ #include "gdl-i18n.h" #include "gdl-switcher.h" -#include "gdl-tools.h" #include "gdl-dock-notebook.h" #include "gdl-dock-tablabel.h" @@ -34,7 +33,6 @@ /* Private prototypes */ static void gdl_dock_notebook_class_init (GdlDockNotebookClass *klass); -static void gdl_dock_notebook_instance_init (GdlDockNotebook *notebook); static void gdl_dock_notebook_set_property (GObject *object, guint prop_id, const GValue *value, @@ -90,7 +88,7 @@ enum { /* ----- Private functions ----- */ -GDL_CLASS_BOILERPLATE (GdlDockNotebook, gdl_dock_notebook, GdlDockItem, GDL_TYPE_DOCK_ITEM) ; +G_DEFINE_TYPE (GdlDockNotebook, gdl_dock_notebook, GDL_TYPE_DOCK_ITEM); static void gdl_dock_notebook_class_init (GdlDockNotebookClass *klass) @@ -179,7 +177,7 @@ gdl_dock_notebook_button_cb (GtkWidget *widget, } static void -gdl_dock_notebook_instance_init (GdlDockNotebook *notebook) +gdl_dock_notebook_init (GdlDockNotebook *notebook) { GdlDockItem *item; @@ -253,7 +251,7 @@ gdl_dock_notebook_destroy (GtkObject *object) /* we need to call the virtual first, since in GdlDockDestroy our children dock objects are detached */ - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_notebook_parent_class)->destroy (object); /* after that we can remove the GtkNotebook */ if (item->child) { @@ -275,7 +273,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))); @@ -327,8 +325,8 @@ gdl_dock_notebook_forall (GtkContainer *container, if (include_internals) { /* use GdlDockItem's forall */ - GDL_CALL_PARENT (GTK_CONTAINER_CLASS, forall, - (container, include_internals, callback, callback_data)); + GTK_CONTAINER_CLASS (gdl_dock_notebook_parent_class)->forall + (container, include_internals, callback, callback_data); } else { item = GDL_DOCK_ITEM (container); @@ -432,8 +430,7 @@ gdl_dock_notebook_dock (GdlDockObject *object, } } else - GDL_CALL_PARENT (GDL_DOCK_OBJECT_CLASS, dock, - (object, requestor, position, other_data)); + GDL_DOCK_OBJECT_CLASS (gdl_dock_notebook_parent_class)->dock (object, requestor, position, other_data); } static void @@ -447,7 +444,7 @@ gdl_dock_notebook_set_orientation (GdlDockItem *item, gtk_notebook_set_tab_pos (GTK_NOTEBOOK (item->child), GTK_POS_LEFT); } - GDL_CALL_PARENT (GDL_DOCK_ITEM_CLASS, set_orientation, (item, orientation)); + GDL_DOCK_ITEM_CLASS (gdl_dock_notebook_parent_class)->set_orientation (item, orientation); } static gboolean @@ -492,7 +489,7 @@ gdl_dock_notebook_present (GdlDockObject *object, if (i >= 0) gtk_notebook_set_current_page (GTK_NOTEBOOK (item->child), i); - GDL_CALL_PARENT (GDL_DOCK_OBJECT_CLASS, present, (object, child)); + GDL_DOCK_OBJECT_CLASS (gdl_dock_notebook_parent_class)->present (object, child); } static gboolean diff --git a/src/libgdl/gdl-dock-object.c b/src/libgdl/gdl-dock-object.c index 28213fe32..4058d8752 100644 --- a/src/libgdl/gdl-dock-object.c +++ b/src/libgdl/gdl-dock-object.c @@ -29,7 +29,6 @@ #include <stdlib.h> #include <string.h> -#include "gdl-tools.h" #include "gdl-dock-object.h" #include "gdl-dock-master.h" #include "libgdltypebuiltins.h" @@ -46,7 +45,6 @@ /* ----- Private prototypes ----- */ static void gdl_dock_object_class_init (GdlDockObjectClass *klass); -static void gdl_dock_object_instance_init (GdlDockObject *object); static void gdl_dock_object_set_property (GObject *g_object, guint prop_id, @@ -96,7 +94,7 @@ static guint gdl_dock_object_signals [LAST_SIGNAL] = { 0 }; /* ----- Private interface ----- */ -GDL_CLASS_BOILERPLATE (GdlDockObject, gdl_dock_object, GtkContainer, GTK_TYPE_CONTAINER); +G_DEFINE_TYPE (GdlDockObject, gdl_dock_object, GTK_TYPE_CONTAINER); static void gdl_dock_object_class_init (GdlDockObjectClass *klass) @@ -193,7 +191,7 @@ gdl_dock_object_class_init (GdlDockObjectClass *klass) } static void -gdl_dock_object_instance_init (GdlDockObject *object) +gdl_dock_object_init (GdlDockObject *object) { object->flags = GDL_DOCK_AUTOMATIC; object->freeze_count = 0; @@ -282,7 +280,7 @@ gdl_dock_object_finalize (GObject *g_object) object->stock_id = NULL; object->pixbuf_icon = NULL; - GDL_CALL_PARENT (G_OBJECT_CLASS, finalize, (g_object)); + G_OBJECT_CLASS (gdl_dock_object_parent_class)->finalize (g_object); } static void @@ -320,7 +318,7 @@ gdl_dock_object_destroy (GtkObject *gtk_object) if (object->master) gdl_dock_object_unbind (object); - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (gtk_object)); + GTK_OBJECT_CLASS(gdl_dock_object_parent_class)->destroy (gtk_object); } static void @@ -341,7 +339,7 @@ gdl_dock_object_show (GtkWidget *widget) (GtkCallback) gdl_dock_object_foreach_automatic, gtk_widget_show); } - GDL_CALL_PARENT (GTK_WIDGET_CLASS, show, (widget)); + GTK_WIDGET_CLASS (gdl_dock_object_parent_class)->show (widget); } static void @@ -352,7 +350,7 @@ gdl_dock_object_hide (GtkWidget *widget) (GtkCallback) gdl_dock_object_foreach_automatic, gtk_widget_hide); } - GDL_CALL_PARENT (GTK_WIDGET_CLASS, hide, (widget)); + GTK_WIDGET_CLASS (gdl_dock_object_parent_class)->hide (widget); } static void @@ -375,8 +373,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 (widget))), widget); if (parent) gdl_dock_object_reduce (parent); } @@ -514,9 +512,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; @@ -560,7 +558,8 @@ gdl_dock_object_reduce (GdlDockObject *object) return; } - GDL_CALL_VIRTUAL (object, GDL_DOCK_OBJECT_GET_CLASS, reduce, (object)); + if (GDL_DOCK_OBJECT_GET_CLASS (object)->reduce) + GDL_DOCK_OBJECT_GET_CLASS (object)->reduce (object); } gboolean @@ -571,11 +570,10 @@ gdl_dock_object_dock_request (GdlDockObject *object, { g_return_val_if_fail (object != NULL && request != NULL, FALSE); - return GDL_CALL_VIRTUAL_WITH_DEFAULT (object, - GDL_DOCK_OBJECT_GET_CLASS, - dock_request, - (object, x, y, request), - FALSE); + if (GDL_DOCK_OBJECT_GET_CLASS (object)->dock_request) + return GDL_DOCK_OBJECT_GET_CLASS (object)->dock_request (object, x, y, request); + else + return FALSE; } /** @@ -696,11 +694,10 @@ gdl_dock_object_reorder (GdlDockObject *object, { g_return_val_if_fail (object != NULL && child != NULL, FALSE); - return GDL_CALL_VIRTUAL_WITH_DEFAULT (object, - GDL_DOCK_OBJECT_GET_CLASS, - reorder, - (object, child, new_position, other_data), - FALSE); + if (GDL_DOCK_OBJECT_GET_CLASS (object)->reorder) + GDL_DOCK_OBJECT_GET_CLASS (object)->reorder (object, child, new_position, other_data); + else + return FALSE; } void @@ -716,7 +713,8 @@ gdl_dock_object_present (GdlDockObject *object, /* chain the call to our parent */ gdl_dock_object_present (parent, object); - GDL_CALL_VIRTUAL (object, GDL_DOCK_OBJECT_GET_CLASS, present, (object, child)); + if (GDL_DOCK_OBJECT_GET_CLASS (object)->present) + GDL_DOCK_OBJECT_GET_CLASS (object)->present (object, child); } /** @@ -749,10 +747,10 @@ gdl_dock_object_child_placement (GdlDockObject *object, if (!gdl_dock_object_is_compound (object)) return FALSE; - return GDL_CALL_VIRTUAL_WITH_DEFAULT (object, GDL_DOCK_OBJECT_GET_CLASS, - child_placement, - (object, child, placement), - FALSE); + if (GDL_DOCK_OBJECT_GET_CLASS (object)->child_placement) + GDL_DOCK_OBJECT_GET_CLASS (object)->child_placement (object, child, placement); + else + return FALSE; } diff --git a/src/libgdl/gdl-dock-paned.c b/src/libgdl/gdl-dock-paned.c index 141770aa2..299384de4 100644 --- a/src/libgdl/gdl-dock-paned.c +++ b/src/libgdl/gdl-dock-paned.c @@ -29,14 +29,13 @@ #include <string.h> #include <gtk/gtk.h> -#include "gdl-tools.h" #include "gdl-dock-paned.h" /* Private prototypes */ static void gdl_dock_paned_class_init (GdlDockPanedClass *klass); -static void gdl_dock_paned_instance_init (GdlDockPaned *paned); +static void gdl_dock_paned_init (GdlDockPaned *paned); static GObject *gdl_dock_paned_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_param); @@ -88,7 +87,7 @@ enum { /* ----- Private functions ----- */ -GDL_CLASS_BOILERPLATE (GdlDockPaned, gdl_dock_paned, GdlDockItem, GDL_TYPE_DOCK_ITEM); +G_DEFINE_TYPE (GdlDockPaned, gdl_dock_paned, GDL_TYPE_DOCK_ITEM); static void gdl_dock_paned_class_init (GdlDockPanedClass *klass) @@ -136,7 +135,7 @@ gdl_dock_paned_class_init (GdlDockPanedClass *klass) } static void -gdl_dock_paned_instance_init (GdlDockPaned *paned) +gdl_dock_paned_init (GdlDockPaned *paned) { paned->position_changed = FALSE; paned->in_drag = FALSE; @@ -347,13 +346,10 @@ gdl_dock_paned_constructor (GType type, GObjectConstructParam *construct_param) { GObject *g_object; - - g_object = GDL_CALL_PARENT_WITH_DEFAULT (G_OBJECT_CLASS, - constructor, - (type, - n_construct_properties, - construct_param), - NULL); + + g_object = G_OBJECT_CLASS (gdl_dock_paned_parent_class)-> constructor (type, + n_construct_properties, + construct_param); if (g_object) { GdlDockItem *item = GDL_DOCK_ITEM (g_object); @@ -416,7 +412,7 @@ gdl_dock_paned_destroy (GtkObject *object) /* we need to call the virtual first, since in GdlDockDestroy our children dock objects are detached */ - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_paned_parent_class)->destroy (object); /* after that we can remove the GtkNotebook */ if (item->child) { @@ -430,8 +426,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)); @@ -439,13 +436,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; @@ -469,8 +469,8 @@ gdl_dock_paned_forall (GtkContainer *container, if (include_internals) { /* use GdlDockItem's forall */ - GDL_CALL_PARENT (GTK_CONTAINER_CLASS, forall, - (container, include_internals, callback, callback_data)); + GTK_CONTAINER_CLASS (gdl_dock_paned_parent_class)->forall + (container, include_internals, callback, callback_data); } else { item = GDL_DOCK_ITEM (container); @@ -520,7 +520,7 @@ gdl_dock_paned_dock_request (GdlDockObject *object, GdlDockItem *item; guint bw; gint rel_x, rel_y; - GtkAllocation *alloc; + GtkAllocation alloc; gboolean may_dock = FALSE; GdlDockRequest my_request; @@ -531,19 +531,19 @@ 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; - rel_y = y - alloc->y; + rel_x = x - alloc.x; + rel_y = y - alloc.y; if (request) my_request = *request; /* Check if coordinates are inside the widget. */ - if (rel_x > 0 && rel_x < alloc->width && - rel_y > 0 && rel_y < alloc->height) { + if (rel_x > 0 && rel_x < alloc.width && + rel_y > 0 && rel_y < alloc.height) { GtkRequisition my, other; gint divider = -1; @@ -556,8 +556,8 @@ gdl_dock_paned_dock_request (GdlDockObject *object, /* Set docking indicator rectangle to the widget size. */ my_request.rect.x = bw; my_request.rect.y = bw; - my_request.rect.width = alloc->width - 2*bw; - my_request.rect.height = alloc->height - 2*bw; + my_request.rect.width = alloc.width - 2*bw; + my_request.rect.height = alloc.height - 2*bw; my_request.target = object; @@ -566,7 +566,7 @@ gdl_dock_paned_dock_request (GdlDockObject *object, my_request.position = GDL_DOCK_LEFT; my_request.rect.width *= SPLIT_RATIO; divider = other.width; - } else if (rel_x > alloc->width - bw) { + } else if (rel_x > alloc.width - bw) { my_request.position = GDL_DOCK_RIGHT; my_request.rect.x += my_request.rect.width * (1 - SPLIT_RATIO); my_request.rect.width *= SPLIT_RATIO; @@ -575,7 +575,7 @@ gdl_dock_paned_dock_request (GdlDockObject *object, my_request.position = GDL_DOCK_TOP; my_request.rect.height *= SPLIT_RATIO; divider = other.height; - } else if (rel_y > alloc->height - bw) { + } else if (rel_y > alloc.height - bw) { my_request.position = GDL_DOCK_BOTTOM; my_request.rect.y += my_request.rect.height * (1 - SPLIT_RATIO); my_request.rect.height *= SPLIT_RATIO; @@ -606,7 +606,7 @@ gdl_dock_paned_dock_request (GdlDockObject *object, or left/right */ may_dock = TRUE; if (item->orientation == GTK_ORIENTATION_HORIZONTAL) { - if (rel_y < alloc->height / 2) { + if (rel_y < alloc.height / 2) { my_request.position = GDL_DOCK_TOP; my_request.rect.height *= SPLIT_RATIO; divider = other.height; @@ -617,7 +617,7 @@ gdl_dock_paned_dock_request (GdlDockObject *object, divider = MAX (0, my.height - other.height); } } else { - if (rel_x < alloc->width / 2) { + if (rel_x < alloc.width / 2) { my_request.position = GDL_DOCK_LEFT; my_request.rect.width *= SPLIT_RATIO; divider = other.width; @@ -641,8 +641,8 @@ gdl_dock_paned_dock_request (GdlDockObject *object, if (may_dock) { /* adjust returned coordinates so they are relative to our allocation */ - my_request.rect.x += alloc->x; - my_request.rect.y += alloc->y; + my_request.rect.x += alloc.x; + my_request.rect.y += alloc.y; } } @@ -659,6 +659,7 @@ gdl_dock_paned_dock (GdlDockObject *object, GValue *other_data) { GtkPaned *paned; + GtkWidget *child1, *child2; gboolean done = FALSE; gboolean hresize = FALSE; gboolean wresize = FALSE; @@ -679,22 +680,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), TRUE, FALSE); done = TRUE; } @@ -705,8 +709,8 @@ gdl_dock_paned_dock (GdlDockObject *object, if (!done) { /* this will create another paned and reparent us there */ - GDL_CALL_PARENT (GDL_DOCK_OBJECT_CLASS, dock, (object, requestor, position, - other_data)); + GDL_DOCK_OBJECT_CLASS (gdl_dock_paned_parent_class)->dock (object, requestor, position, + other_data); } else { gdl_dock_item_show_grip (GDL_DOCK_ITEM (requestor)); @@ -735,8 +739,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); @@ -752,7 +756,7 @@ gdl_dock_paned_set_orientation (GdlDockItem *item, } } - GDL_CALL_PARENT (GDL_DOCK_ITEM_CLASS, set_orientation, (item, orientation)); + GDL_DOCK_ITEM_CLASS (gdl_dock_paned_parent_class)->set_orientation (item, orientation); } static gboolean @@ -766,10 +770,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/src/libgdl/gdl-dock-placeholder.c b/src/libgdl/gdl-dock-placeholder.c index a4b84b56f..b8fba9723 100644 --- a/src/libgdl/gdl-dock-placeholder.c +++ b/src/libgdl/gdl-dock-placeholder.c @@ -27,7 +27,6 @@ #include "gdl-i18n.h" -#include "gdl-tools.h" #include "gdl-dock-placeholder.h" #include "gdl-dock-item.h" #include "gdl-dock-paned.h" @@ -40,7 +39,6 @@ /* ----- Private prototypes ----- */ static void gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass); -static void gdl_dock_placeholder_instance_init (GdlDockPlaceholder *ph); static void gdl_dock_placeholder_set_property (GObject *g_object, guint prop_id, @@ -120,8 +118,7 @@ struct _GdlDockPlaceholderPrivate { /* ----- Private interface ----- */ -GDL_CLASS_BOILERPLATE (GdlDockPlaceholder, gdl_dock_placeholder, - GdlDockObject, GDL_TYPE_DOCK_OBJECT); +G_DEFINE_TYPE (GdlDockPlaceholder, gdl_dock_placeholder, GDL_TYPE_DOCK_OBJECT); static void gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass) @@ -214,10 +211,9 @@ gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass) } static void -gdl_dock_placeholder_instance_init (GdlDockPlaceholder *ph) +gdl_dock_placeholder_init (GdlDockPlaceholder *ph) { gtk_widget_set_has_window (GTK_WIDGET (ph), FALSE); - gtk_widget_set_can_focus (GTK_WIDGET (ph), FALSE); ph->_priv = g_new0 (GdlDockPlaceholderPrivate, 1); @@ -327,7 +323,7 @@ gdl_dock_placeholder_destroy (GtkObject *object) ph->_priv = NULL; } - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_placeholder_parent_class)->destroy (object); } static void @@ -378,6 +374,7 @@ find_biggest_dock_item (GtkContainer *container, GtkWidget **biggest_child, gint *biggest_child_area) { GList *children, *child; + GtkAllocation allocation; children = gtk_container_get_children (GTK_CONTAINER (container)); child = children; @@ -393,7 +390,8 @@ find_biggest_dock_item (GtkContainer *container, GtkWidget **biggest_child, child = g_list_next (child); continue; } - area = child_widget->allocation.width * child_widget->allocation.height; + gtk_widget_get_allocation (child_widget, &allocation); + area = allocation.width * allocation.height; if (area > *biggest_child_area) { *biggest_child_area = area; @@ -409,8 +407,13 @@ attempt_to_dock_on_host (GdlDockPlaceholder *ph, GdlDockObject *host, gpointer other_data) { GdlDockObject *parent; - gint host_width = GTK_WIDGET (host)->allocation.width; - gint host_height = GTK_WIDGET (host)->allocation.height; + GtkAllocation allocation; + gint host_width; + gint host_height; + + gtk_widget_get_allocation (GTK_WIDGET (host), &allocation); + host_width = allocation.width; + host_height = allocation.height; if (placement != GDL_DOCK_CENTER || !GDL_IS_DOCK_PANED (host)) { /* we simply act as a proxy for our host */ diff --git a/src/libgdl/gdl-dock-tablabel.c b/src/libgdl/gdl-dock-tablabel.c index fb233fc3e..65f87ab1d 100644 --- a/src/libgdl/gdl-dock-tablabel.c +++ b/src/libgdl/gdl-dock-tablabel.c @@ -29,7 +29,6 @@ #include <gtk/gtk.h> #include "gdl-dock-tablabel.h" -#include "gdl-tools.h" #include "gdl-dock-item.h" #include "libgdlmarshal.h" @@ -37,7 +36,6 @@ /* ----- Private prototypes ----- */ static void gdl_dock_tablabel_class_init (GdlDockTablabelClass *klass); -static void gdl_dock_tablabel_instance_init (GdlDockTablabel *tablabel); static void gdl_dock_tablabel_set_property (GObject *object, guint prop_id, @@ -93,8 +91,7 @@ static guint dock_tablabel_signals [LAST_SIGNAL] = { 0 }; /* ----- Private interface ----- */ -GDL_CLASS_BOILERPLATE (GdlDockTablabel, gdl_dock_tablabel, - GtkBin, GTK_TYPE_BIN); +G_DEFINE_TYPE (GdlDockTablabel, gdl_dock_tablabel, GTK_TYPE_BIN); static void gdl_dock_tablabel_class_init (GdlDockTablabelClass *klass) @@ -146,7 +143,7 @@ gdl_dock_tablabel_class_init (GdlDockTablabelClass *klass) } static void -gdl_dock_tablabel_instance_init (GdlDockTablabel *tablabel) +gdl_dock_tablabel_init (GdlDockTablabel *tablabel) { GtkWidget *widget; GtkWidget *label_widget; @@ -212,9 +209,9 @@ gdl_dock_tablabel_set_property (GObject *object, tablabel->drag_handle_size = 0; bin = GTK_BIN (tablabel); - if (bin->child && g_object_class_find_property ( - G_OBJECT_GET_CLASS (bin->child), "label")) - g_object_set (bin->child, "label", long_name, NULL); + if (gtk_bin_get_child (bin) && g_object_class_find_property ( + G_OBJECT_GET_CLASS (gtk_bin_get_child (bin)), "label")) + g_object_set (gtk_bin_get_child (bin), "label", long_name, NULL); g_free (long_name); }; break; @@ -266,9 +263,9 @@ gdl_dock_tablabel_item_notify (GObject *master, tablabel->drag_handle_size = 0; bin = GTK_BIN (tablabel); - if (bin->child && g_object_class_find_property ( - G_OBJECT_GET_CLASS (bin->child), "label")) - g_object_set (bin->child, "label", label, NULL); + if (gtk_bin_get_child (bin) && g_object_class_find_property ( + G_OBJECT_GET_CLASS (gtk_bin_get_child (bin)), "label")) + g_object_set (gtk_bin_get_child (bin), "label", label, NULL); g_free (label); gtk_widget_queue_resize (GTK_WIDGET (tablabel)); @@ -281,6 +278,7 @@ gdl_dock_tablabel_size_request (GtkWidget *widget, GtkBin *bin; GtkRequisition child_req; GdlDockTablabel *tablabel; + guint border_width; g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK_TABLABEL (widget)); @@ -292,18 +290,20 @@ gdl_dock_tablabel_size_request (GtkWidget *widget, requisition->width = tablabel->drag_handle_size; requisition->height = 0; - if (bin->child) - gtk_widget_size_request (bin->child, &child_req); + if (gtk_bin_get_child (bin)) + gtk_widget_size_request (gtk_bin_get_child (bin), &child_req); else child_req.width = child_req.height = 0; requisition->width += child_req.width; requisition->height += child_req.height; - requisition->width += GTK_CONTAINER (widget)->border_width * 2; - requisition->height += GTK_CONTAINER (widget)->border_width * 2; + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - widget->requisition = *requisition; + requisition->width += border_width * 2; + requisition->height += border_width * 2; + + //gtk_widget_size_request (widget, requisition); } static void @@ -311,6 +311,7 @@ gdl_dock_tablabel_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { GtkBin *bin; + GtkAllocation widget_allocation; GdlDockTablabel *tablabel; gint border_width; @@ -321,9 +322,9 @@ gdl_dock_tablabel_size_allocate (GtkWidget *widget, bin = GTK_BIN (widget); tablabel = GDL_DOCK_TABLABEL (widget); - border_width = GTK_CONTAINER (widget)->border_width; + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) gdk_window_move_resize (tablabel->event_window, @@ -332,11 +333,12 @@ gdl_dock_tablabel_size_allocate (GtkWidget *widget, allocation->width, allocation->height); - if (bin->child && gtk_widget_get_visible (bin->child)) { + if (gtk_bin_get_child (bin) && gtk_widget_get_visible (gtk_bin_get_child (bin))) { GtkAllocation child_allocation; - child_allocation.x = widget->allocation.x + border_width; - child_allocation.y = widget->allocation.y + border_width; + gtk_widget_get_allocation (widget, &widget_allocation); + child_allocation.x = widget_allocation.x + border_width; + child_allocation.y = widget_allocation.y + border_width; allocation->width = MAX (1, (int) allocation->width - (int) tablabel->drag_handle_size); @@ -347,7 +349,7 @@ gdl_dock_tablabel_size_allocate (GtkWidget *widget, child_allocation.height = MAX (1, (int) allocation->height - 2 * border_width); - gtk_widget_size_allocate (bin->child, &child_allocation); + gtk_widget_size_allocate (gtk_bin_get_child (bin), &child_allocation); } } @@ -357,20 +359,22 @@ gdl_dock_tablabel_paint (GtkWidget *widget, { GdkRectangle dest, rect; GtkBin *bin; + GtkAllocation widget_allocation; GdlDockTablabel *tablabel; gint border_width; bin = GTK_BIN (widget); tablabel = GDL_DOCK_TABLABEL (widget); - border_width = GTK_CONTAINER (widget)->border_width; + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - rect.x = widget->allocation.x + border_width; - rect.y = widget->allocation.y + border_width; + gtk_widget_get_allocation (widget, &widget_allocation); + rect.x = widget_allocation.x + border_width; + rect.y = widget_allocation.y + border_width; rect.width = tablabel->drag_handle_size * HANDLE_RATIO; - rect.height = widget->allocation.height - 2*border_width; + rect.height = widget_allocation.height - 2*border_width; if (gdk_rectangle_intersect (&event->area, &rect, &dest)) { - gtk_paint_handle (widget->style, widget->window, + gtk_paint_handle (gtk_widget_get_style (widget), gtk_widget_get_window (widget), tablabel->active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, GTK_SHADOW_NONE, &dest, widget, "dock-tablabel", @@ -388,7 +392,7 @@ gdl_dock_tablabel_expose (GtkWidget *widget, g_return_val_if_fail (event != NULL, FALSE); if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget)) { - GDL_CALL_PARENT_GBOOLEAN(GTK_WIDGET_CLASS, expose_event, (widget,event)); + GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->expose_event (widget,event); gdl_dock_tablabel_paint (widget, event); }; @@ -400,6 +404,7 @@ gdl_dock_tablabel_button_event (GtkWidget *widget, GdkEventButton *event) { GdlDockTablabel *tablabel; + GtkAllocation widget_allocation; gboolean event_handled; g_return_val_if_fail (widget != NULL, FALSE); @@ -422,7 +427,7 @@ gdl_dock_tablabel_button_event (GtkWidget *widget, GtkBin *bin; bin = GTK_BIN (widget); - border_width = GTK_CONTAINER (widget)->border_width; + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); rel_x = event->x - border_width; rel_y = event->y - border_width; @@ -460,8 +465,9 @@ gdl_dock_tablabel_button_event (GtkWidget *widget, e = *event; e.window = gtk_widget_get_parent_window (widget); - e.x += widget->allocation.x; - e.y += widget->allocation.y; + gtk_widget_get_allocation (widget, &widget_allocation); + e.x += widget_allocation.x; + e.y += widget_allocation.y; gdk_event_put ((GdkEvent *) &e); }; @@ -474,6 +480,7 @@ gdl_dock_tablabel_motion_event (GtkWidget *widget, GdkEventMotion *event) { GdlDockTablabel *tablabel; + GtkAllocation widget_allocation; gboolean event_handled; g_return_val_if_fail (widget != NULL, FALSE); @@ -508,8 +515,9 @@ gdl_dock_tablabel_motion_event (GtkWidget *widget, e = *event; e.window = gtk_widget_get_parent_window (widget); - e.x += widget->allocation.x; - e.y += widget->allocation.y; + gtk_widget_get_allocation (widget, &widget_allocation); + e.x += widget_allocation.x; + e.y += widget_allocation.y; gdk_event_put ((GdkEvent *) &e); }; @@ -522,15 +530,17 @@ gdl_dock_tablabel_realize (GtkWidget *widget) { GdlDockTablabel *tablabel; GdkWindowAttr attributes; + GtkAllocation widget_allocation; int attributes_mask; tablabel = GDL_DOCK_TABLABEL (widget); attributes.window_type = GDK_WINDOW_CHILD; - 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, &widget_allocation); + attributes.x = widget_allocation.x; + attributes.y = widget_allocation.y; + attributes.width = widget_allocation.width; + attributes.height = widget_allocation.height; attributes.wclass = GDK_INPUT_ONLY; attributes.event_mask = gtk_widget_get_events (widget); attributes.event_mask |= (GDK_EXPOSURE_MASK | @@ -541,15 +551,16 @@ gdl_dock_tablabel_realize (GtkWidget *widget) GDK_LEAVE_NOTIFY_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y; - widget->window = gtk_widget_get_parent_window (widget); - g_object_ref (widget->window); + gtk_widget_set_window (widget, gtk_widget_get_parent_window (widget)); + g_object_ref (gtk_widget_get_window (widget)); tablabel->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (tablabel->event_window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); + + gtk_widget_set_style (widget, gtk_style_attach (gtk_widget_get_style (widget), + gtk_widget_get_window (widget))); gtk_widget_set_realized (widget, TRUE); } @@ -565,15 +576,15 @@ gdl_dock_tablabel_unrealize (GtkWidget *widget) tablabel->event_window = NULL; } - GDL_CALL_PARENT (GTK_WIDGET_CLASS, unrealize, (widget)); + GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->unrealize (widget); } static void gdl_dock_tablabel_map (GtkWidget *widget) { GdlDockTablabel *tablabel = GDL_DOCK_TABLABEL (widget); - - GDL_CALL_PARENT (GTK_WIDGET_CLASS, map, (widget)); + + GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->map (widget); gdk_window_show (tablabel->event_window); } @@ -585,7 +596,7 @@ gdl_dock_tablabel_unmap (GtkWidget *widget) gdk_window_hide (tablabel->event_window); - GDL_CALL_PARENT (GTK_WIDGET_CLASS, unmap, (widget)); + GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->unmap (widget); } /* ----- Public interface ----- */ diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c index c82fead9c..3b90f3757 100644 --- a/src/libgdl/gdl-dock.c +++ b/src/libgdl/gdl-dock.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * This file is part of the GNOME Devtools Libraries. * @@ -28,7 +28,6 @@ #include <stdlib.h> #include <string.h> -#include "gdl-tools.h" #include "gdl-dock.h" #include "gdl-dock-master.h" #include "gdl-dock-paned.h" @@ -41,7 +40,6 @@ /* ----- Private prototypes ----- */ static void gdl_dock_class_init (GdlDockClass *class); -static void gdl_dock_instance_init (GdlDock *dock); static GObject *gdl_dock_constructor (GType type, guint n_construct_properties, @@ -147,7 +145,7 @@ static guint dock_signals [LAST_SIGNAL] = { 0 }; /* ----- Private functions ----- */ -GDL_CLASS_BOILERPLATE (GdlDock, gdl_dock, GdlDockObject, GDL_TYPE_DOCK_OBJECT); +G_DEFINE_TYPE (GdlDock, gdl_dock, GDL_TYPE_DOCK_OBJECT); static void gdl_dock_class_init (GdlDockClass *klass) @@ -258,7 +256,7 @@ gdl_dock_class_init (GdlDockClass *klass) } static void -gdl_dock_instance_init (GdlDock *dock) +gdl_dock_init (GdlDock *dock) { gtk_widget_set_has_window (GTK_WIDGET (dock), FALSE); @@ -294,17 +292,14 @@ gdl_dock_constructor (GType type, GObjectConstructParam *construct_param) { GObject *g_object; - - g_object = GDL_CALL_PARENT_WITH_DEFAULT (G_OBJECT_CLASS, - constructor, - (type, - n_construct_properties, - construct_param), - NULL); + + g_object = G_OBJECT_CLASS (gdl_dock_parent_class)-> constructor (type, + n_construct_properties, + construct_param); if (g_object) { GdlDock *dock = GDL_DOCK (g_object); GdlDockMaster *master; - + /* create a master for the dock if none was provided in the construction */ master = GDL_DOCK_OBJECT_GET_MASTER (GDL_DOCK_OBJECT (dock)); if (!master) { @@ -316,11 +311,11 @@ gdl_dock_constructor (GType type, if (dock->_priv->floating) { GdlDockObject *controller; - + /* create floating window for this dock */ dock->_priv->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); g_object_set_data (G_OBJECT (dock->_priv->window), "dock", dock); - + /* set position and default size */ gtk_window_set_position (GTK_WINDOW (dock->_priv->window), GTK_WIN_POS_MOUSE); @@ -337,27 +332,27 @@ gdl_dock_constructor (GType type, gtk_window_move (GTK_WINDOW (dock->_priv->window), dock->_priv->float_x, dock->_priv->float_y); - + /* connect to the configure event so we can track down window geometry */ g_signal_connect (dock->_priv->window, "configure_event", (GCallback) gdl_dock_floating_configure_event_cb, dock); - + /* set the title and connect to the long_name notify queue - so we can reset the title when this prop changes */ + so we can reset the title when this prop changes */ gdl_dock_set_title (dock); g_signal_connect (dock, "notify::long-name", (GCallback) gdl_dock_notify_cb, NULL); - + gtk_container_add (GTK_CONTAINER (dock->_priv->window), GTK_WIDGET (dock)); - + g_signal_connect (dock->_priv->window, "delete_event", G_CALLBACK (gdl_dock_floating_window_delete_event_cb), NULL); } GDL_DOCK_OBJECT_SET_FLAGS (dock, GDL_DOCK_ATTACHED); } - + return g_object; } @@ -502,8 +497,6 @@ gdl_dock_notify_cb (GObject *object, g_object_get (object, "long-name", &long_name, NULL); - g_message ("Notify long_name: %s", long_name); - if (long_name) { dock = GDL_DOCK (object); @@ -537,7 +530,7 @@ gdl_dock_destroy (GtkObject *object) g_free (priv); } - GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (gdl_dock_parent_class)->destroy (object); } static void @@ -553,7 +546,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))) @@ -566,7 +559,7 @@ gdl_dock_size_request (GtkWidget *widget, requisition->width += 2 * border_width; requisition->height += 2 * border_width; - widget->requisition = *requisition; + //gtk_widget_size_request (widget, requisition); } static void @@ -582,9 +575,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; @@ -607,7 +600,7 @@ gdl_dock_map (GtkWidget *widget) dock = GDL_DOCK (widget); - GDL_CALL_PARENT (GTK_WIDGET_CLASS, map, (widget)); + GTK_WIDGET_CLASS (gdl_dock_parent_class)->map (widget); if (dock->root) { child = GTK_WIDGET (dock->root); @@ -627,7 +620,7 @@ gdl_dock_unmap (GtkWidget *widget) dock = GDL_DOCK (widget); - GDL_CALL_PARENT (GTK_WIDGET_CLASS, unmap, (widget)); + GTK_WIDGET_CLASS (gdl_dock_parent_class)->unmap (widget); if (dock->root) { child = GTK_WIDGET (dock->root); @@ -657,7 +650,7 @@ gdl_dock_show (GtkWidget *widget) g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); - GDL_CALL_PARENT (GTK_WIDGET_CLASS, show, (widget)); + GTK_WIDGET_CLASS (gdl_dock_parent_class)->show (widget); dock = GDL_DOCK (widget); if (dock->_priv->floating && dock->_priv->window) @@ -678,7 +671,7 @@ gdl_dock_hide (GtkWidget *widget) g_return_if_fail (widget != NULL); g_return_if_fail (GDL_IS_DOCK (widget)); - GDL_CALL_PARENT (GTK_WIDGET_CLASS, hide, (widget)); + GTK_WIDGET_CLASS (gdl_dock_parent_class)->hide (widget); dock = GDL_DOCK (widget); if (dock->_priv->floating && dock->_priv->window) @@ -771,6 +764,7 @@ static void gdl_dock_reduce (GdlDockObject *object) { GdlDock *dock = GDL_DOCK (object); + GtkWidget *parent; if (dock->root) return; @@ -784,8 +778,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); } } } @@ -799,7 +794,7 @@ gdl_dock_dock_request (GdlDockObject *object, GdlDock *dock; guint bw; gint rel_x, rel_y; - GtkAllocation *alloc; + GtkAllocation alloc; gboolean may_dock = FALSE; GdlDockRequest my_request; @@ -810,28 +805,28 @@ 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; - rel_y = y - alloc->y; + rel_x = x - alloc.x; + rel_y = y - alloc.y; if (request) my_request = *request; /* Check if coordinates are in GdlDock widget. */ - if (rel_x > 0 && rel_x < alloc->width && - rel_y > 0 && rel_y < alloc->height) { + if (rel_x > 0 && rel_x < alloc.width && + rel_y > 0 && rel_y < alloc.height) { /* It's inside our area. */ may_dock = TRUE; /* Set docking indicator rectangle to the GdlDock size. */ - my_request.rect.x = alloc->x + bw; - my_request.rect.y = alloc->y + bw; - my_request.rect.width = alloc->width - 2*bw; - my_request.rect.height = alloc->height - 2*bw; + my_request.rect.x = alloc.x + bw; + my_request.rect.y = alloc.y + bw; + my_request.rect.width = alloc.width - 2*bw; + my_request.rect.height = alloc.height - 2*bw; /* If GdlDock has no root item yet, set the dock itself as possible target. */ @@ -845,14 +840,14 @@ gdl_dock_dock_request (GdlDockObject *object, if (rel_x < bw) { my_request.position = GDL_DOCK_LEFT; my_request.rect.width *= SPLIT_RATIO; - } else if (rel_x > alloc->width - bw) { + } else if (rel_x > alloc.width - bw) { my_request.position = GDL_DOCK_RIGHT; my_request.rect.x += my_request.rect.width * (1 - SPLIT_RATIO); my_request.rect.width *= SPLIT_RATIO; } else if (rel_y < bw) { my_request.position = GDL_DOCK_TOP; my_request.rect.height *= SPLIT_RATIO; - } else if (rel_y > alloc->height - bw) { + } else if (rel_y > alloc.height - bw) { my_request.position = GDL_DOCK_BOTTOM; my_request.rect.y += my_request.rect.height * (1 - SPLIT_RATIO); my_request.rect.height *= SPLIT_RATIO; @@ -1068,17 +1063,20 @@ 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_TOP; } } @@ -1335,6 +1333,7 @@ gdl_dock_xor_rect (GdlDock *dock, GdkRectangle *rect) { GtkWidget *widget; + GdkWindow *window; gint8 dash_list [2]; widget = GTK_WIDGET (dock); @@ -1346,7 +1345,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; }; @@ -1355,19 +1354,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); } diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c index 895e708a5..183ae66c0 100644 --- a/src/libgdl/gdl-switcher.c +++ b/src/libgdl/gdl-switcher.c @@ -32,7 +32,6 @@ #include "gdl-i18n.h" #include "gdl-switcher.h" -#include "gdl-tools.h" #include "libgdlmarshal.h" #include "libgdltypebuiltins.h" @@ -89,7 +88,7 @@ struct _GdlSwitcherPrivate { gboolean in_toggle; }; -GDL_CLASS_BOILERPLATE (GdlSwitcher, gdl_switcher, GtkNotebook, GTK_TYPE_NOTEBOOK) +G_DEFINE_TYPE (GdlSwitcher, gdl_switcher, GTK_TYPE_NOTEBOOK) #define INTERNAL_MODE(switcher) (switcher->priv->switcher_style == \ GDL_SWITCHER_STYLE_TOOLBAR ? switcher->priv->toolbar_style : \ @@ -257,7 +256,7 @@ static int layout_buttons (GdlSwitcher *switcher) { GtkRequisition client_requisition = {0,}; - GtkAllocation *allocation = & GTK_WIDGET (switcher)->allocation; + GtkAllocation allocation; GdlSwitcherStyle switcher_style; gboolean icons_only; int num_btns = g_slist_length (switcher->priv->buttons); @@ -272,13 +271,14 @@ layout_buttons (GdlSwitcher *switcher) int i; int rows_count; int last_buttons_height; + + gtk_widget_get_allocation (GTK_WIDGET (switcher), &allocation); last_buttons_height = switcher->priv->buttons_height_request; - GDL_CALL_PARENT (GTK_WIDGET_CLASS, size_request, - (GTK_WIDGET (switcher), &client_requisition)); + GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_request (GTK_WIDGET (switcher), &client_requisition); - y = allocation->y + allocation->height - V_PADDING - 1; + y = allocation.y + allocation.height - V_PADDING - 1; if (num_btns == 0) return y; @@ -300,10 +300,10 @@ layout_buttons (GdlSwitcher *switcher) } /* Figure out how many rows and columns we'll use. */ - btns_per_row = allocation->width / (max_btn_width + H_PADDING); + btns_per_row = allocation.width / (max_btn_width + H_PADDING); /* If all the buttons could fit in the single row, have it so */ - if (allocation->width >= optimal_layout_width) + if (allocation.width >= optimal_layout_width) { btns_per_row = num_btns; } @@ -380,7 +380,7 @@ layout_buttons (GdlSwitcher *switcher) /* Check for possible size over flow (taking into account client * requisition */ - if (y < (allocation->y + client_requisition.height)) { + if (y < (allocation.y + client_requisition.height)) { /* We have an overflow: Insufficient allocation */ if (last_buttons_height < switcher->priv->buttons_height_request) { /* Request for a new resize */ @@ -388,11 +388,11 @@ layout_buttons (GdlSwitcher *switcher) return -1; } } - x = H_PADDING + allocation->x; + x = H_PADDING + allocation.x; len = g_slist_length (rows[i]); if (switcher_style == GDL_SWITCHER_STYLE_TEXT || switcher_style == GDL_SWITCHER_STYLE_BOTH) - extra_width = (allocation->width - (len * max_btn_width ) + extra_width = (allocation.width - (len * max_btn_width ) - (len * H_PADDING)) / len; else extra_width = 0; @@ -432,26 +432,27 @@ layout_buttons (GdlSwitcher *switcher) static void do_layout (GdlSwitcher *switcher) { - GtkAllocation *allocation = & GTK_WIDGET (switcher)->allocation; + GtkAllocation allocation; GtkAllocation child_allocation; int y; + gtk_widget_get_allocation (GTK_WIDGET (switcher), &allocation); + if (switcher->priv->show) { y = layout_buttons (switcher); if (y < 0) /* Layout did not happen and a resize was requested */ return; } else - y = allocation->y + allocation->height; + y = allocation.y + allocation.height; /* Place the parent widget. */ - child_allocation.x = allocation->x; - child_allocation.y = allocation->y; - child_allocation.width = allocation->width; - child_allocation.height = y - allocation->y; + child_allocation.x = allocation.x; + child_allocation.y = allocation.y; + child_allocation.width = allocation.width; + child_allocation.height = y - allocation.y; - GDL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, - (GTK_WIDGET (switcher), &child_allocation)); + GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_allocate (GTK_WIDGET (switcher), &child_allocation); } /* GtkContainer methods. */ @@ -464,9 +465,9 @@ gdl_switcher_forall (GtkContainer *container, gboolean include_internals, GDL_SWITCHER (container); GSList *p; - GDL_CALL_PARENT (GTK_CONTAINER_CLASS, forall, - (GTK_CONTAINER (switcher), include_internals, - callback, callback_data)); + GTK_CONTAINER_CLASS (gdl_switcher_parent_class)->forall (GTK_CONTAINER (switcher), + include_internals, + callback, callback_data); if (include_internals) { for (p = switcher->priv->buttons; p != NULL; p = p->next) { GtkWidget *widget = ((Button *) p->data)->button_widget; @@ -496,8 +497,7 @@ gdl_switcher_remove (GtkContainer *container, GtkWidget *widget) break; } } - GDL_CALL_PARENT (GTK_CONTAINER_CLASS, remove, - (GTK_CONTAINER (switcher), widget)); + GTK_CONTAINER_CLASS (gdl_switcher_parent_class)->remove (GTK_CONTAINER (switcher), widget); } /* GtkWidget methods. */ @@ -509,8 +509,7 @@ gdl_switcher_size_request (GtkWidget *widget, GtkRequisition *requisition) GSList *p; gint button_height = 0; - GDL_CALL_PARENT (GTK_WIDGET_CLASS, size_request, - (GTK_WIDGET (switcher), requisition)); + GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_request (GTK_WIDGET (switcher), requisition); if (!switcher->priv->show) return; @@ -537,7 +536,7 @@ gdl_switcher_size_request (GtkWidget *widget, GtkRequisition *requisition) static void gdl_switcher_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { - widget->allocation = *allocation; + gtk_widget_set_allocation (widget, allocation); do_layout (GDL_SWITCHER (widget)); } @@ -553,8 +552,7 @@ gdl_switcher_expose (GtkWidget *widget, GdkEventExpose *event) button, event); } } - return GDL_CALL_PARENT_WITH_DEFAULT (GTK_WIDGET_CLASS, expose_event, - (widget, event), FALSE); + return GTK_WIDGET_CLASS (gdl_switcher_parent_class)->expose_event (widget, event); } static void @@ -569,7 +567,7 @@ gdl_switcher_map (GtkWidget *widget) gtk_widget_map (button); } } - GDL_CALL_PARENT (GTK_WIDGET_CLASS, map, (widget)); + GTK_WIDGET_CLASS (gdl_switcher_parent_class)->map (widget); } /* GObject methods. */ @@ -629,7 +627,7 @@ gdl_switcher_dispose (GObject *object) g_slist_free (priv->buttons); priv->buttons = NULL; - GDL_CALL_PARENT (G_OBJECT_CLASS, dispose, (object)); + G_OBJECT_CLASS (gdl_switcher_parent_class)->dispose (object); } static void @@ -639,7 +637,7 @@ gdl_switcher_finalize (GObject *object) g_free (priv); - GDL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); + G_OBJECT_CLASS (gdl_switcher_parent_class)->finalize (object); } /* Signal handlers */ @@ -748,7 +746,7 @@ gdl_switcher_class_init (GdlSwitcherClass *klass) } static void -gdl_switcher_instance_init (GdlSwitcher *switcher) +gdl_switcher_init (GdlSwitcher *switcher) { GdlSwitcherPrivate *priv; diff --git a/src/libgdl/gdl-tools.h b/src/libgdl/gdl-tools.h deleted file mode 100644 index 4e515b23b..000000000 --- a/src/libgdl/gdl-tools.h +++ /dev/null @@ -1,187 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the GNOME Devtool Libraries - * - * Copyright (C) 1999-2000 Dave Camp <dave@helixcode.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Miscellaneous GDL tools/macros */ - -#ifndef __GDL_TOOLS_H__ -#define __GDL_TOOLS_H__ - -#include <glib.h> -#include <gtk/gtk.h> - -/* FIXME: Toggle this */ - -G_BEGIN_DECLS - -#define DO_GDL_TRACE - -#ifdef DO_GDL_TRACE - -#ifdef __GNUC__ - -#define GDL_TRACE() G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_DEBUG, \ - "file %s: line %d (%s)", \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__); } G_STMT_END - -#define GDL_TRACE_EXTRA(format, args...) G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_DEBUG, \ - "file %s: line %d (%s): "format, \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__, \ - ##args); } G_STMT_END - -#else /* __GNUC__ */ - -#define GDL_TRACE() G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_DEBUG, \ - "file %s: line %d", \ - __FILE__, \ - __LINE__); } G_STMT_END - -#define GDL_TRACE_EXTRA(format, args...) G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_DEBUG, \ - "file %s: line %d: "format, \ - __FILE__, \ - __LINE__, \ - ##args); } G_STMT_END -#endif /* __GNUC__ */ - -#else /* DO_GDL_TRACE */ - -#define GDL_TRACE() -#define GDL_TRACE_EXTRA() - -#endif /* DO_GDL_TRACE */ - -/* - * Class boilerplate and base class call macros copied from - * bonobo/bonobo-macros.h. Original copyright follows. - * - * - * Author: - * Darin Adler <darin@bentspoon.com> - * - * Copyright 2001 Ben Tea Spoons, Inc. - */ - -/* Macros for defining classes. Ideas taken from Nautilus and GOB. */ - -/* Define the boilerplate type stuff to reduce typos and code size. Defines - * the get_type method and the parent_class static variable. */ - -#define GDL_BOILERPLATE(type, type_as_function, corba_type, \ - parent_type, parent_type_macro, \ - register_type_macro) \ -static void type_as_function ## _class_init (type ## Class *klass); \ -static void type_as_function ## _instance_init (type *object); \ -static parent_type ## Class *parent_class = NULL; \ -static void \ -type_as_function ## _class_init_trampoline (gpointer klass, \ - gpointer data) \ -{ \ - (void)data; \ - parent_class = (parent_type ## Class *)g_type_class_ref ( \ - parent_type_macro); \ - type_as_function ## _class_init ((type ## Class *)klass); \ -} \ -GType \ -type_as_function ## _get_type (void) \ -{ \ - static GType object_type = 0; \ - if (object_type == 0) { \ - static const GTypeInfo object_info = { \ - sizeof (type ## Class), \ - NULL, /* base_init */ \ - NULL, /* base_finalize */ \ - type_as_function ## _class_init_trampoline, \ - NULL, /* class_finalize */ \ - NULL, /* class_data */ \ - sizeof (type), \ - 0, /* n_preallocs */ \ - (GInstanceInitFunc) type_as_function ## _instance_init , \ - NULL, /* value_table */ \ - }; \ - object_type = register_type_macro \ - (type, type_as_function, corba_type, \ - parent_type, parent_type_macro); \ - } \ - return object_type; \ -} - -/* Just call the parent handler. This assumes that there is a variable - * named parent_class that points to the (duh!) parent class. Note that - * this macro is not to be used with things that return something, use - * the _WITH_DEFAULT version for that */ -#define GDL_CALL_PARENT(parent_class_cast, name, args) \ - ((parent_class_cast(parent_class)->name != NULL) ? \ - parent_class_cast(parent_class)->name args : (void)0) - -#define GDL_CALL_PARENT_GBOOLEAN(parent_class_cast, name, args) \ - ((parent_class_cast(parent_class)->name != NULL) ? \ - parent_class_cast(parent_class)->name args : (gboolean)0) - - -/* Same as above, but in case there is no implementation, it evaluates - * to def_return */ -#define GDL_CALL_PARENT_WITH_DEFAULT(parent_class_cast, \ - name, args, def_return) \ - ((parent_class_cast(parent_class)->name != NULL) ? \ - parent_class_cast(parent_class)->name args : def_return) - -/* Define the boilerplate type stuff to reduce typos and code size. Defines - * the get_type method and the parent_class static variable. */ -#define GDL_CLASS_BOILERPLATE(type, type_as_function, \ - parent_type, parent_type_macro) \ - GDL_BOILERPLATE(type, type_as_function, type, \ - parent_type, parent_type_macro, \ - GDL_REGISTER_TYPE) -#define GDL_REGISTER_TYPE(type, type_as_function, corba_type, \ - parent_type, parent_type_macro) \ - g_type_register_static (parent_type_macro, #type, &object_info, 0) - - -#define GDL_CALL_VIRTUAL(object, get_class_cast, method, args) \ - (get_class_cast (object)->method ? (* get_class_cast (object)->method) args : (void)0) -#define GDL_CALL_VIRTUAL_WITH_DEFAULT(object, get_class_cast, method, args, default) \ - (get_class_cast (object)->method ? (* get_class_cast (object)->method) args : default) - -/* GdlPixmap structure and method have been copied from Evolution. */ -typedef struct _GdlPixmap { - const char *path; - const char *fname; - char *pixbuf; -} GdlPixmap; - -#define GDL_PIXMAP(path,fname) { (path), (fname), NULL } -#define GDL_PIXMAP_END { NULL, NULL, NULL } - -G_END_DECLS - -#endif - diff --git a/src/libgdl/gdl.h b/src/libgdl/gdl.h index d136b9295..235c5e3eb 100644 --- a/src/libgdl/gdl.h +++ b/src/libgdl/gdl.h @@ -22,7 +22,6 @@ #ifndef __GDL_H__ #define __GDL_H__ -#include "libgdl/gdl-tools.h" #include "libgdl/gdl-dock-object.h" #include "libgdl/gdl-dock-master.h" #include "libgdl/gdl-dock.h" |
