summaryrefslogtreecommitdiffstats
path: root/src/libgdl
diff options
context:
space:
mode:
authorAndrew Higginson <at.higginson@gmail.com>2011-12-27 21:04:47 +0000
committerAndrew <at.higginson@gmail.com>2011-12-27 21:04:47 +0000
commit80960b623a99aae1402ab651b2974ef544ed3b03 (patch)
treeba49d42c2789e9e11f805e2d5263e10f9fedeef8 /src/libgdl
parenttry to fix bug (diff)
parentGDL: Cherry-pick upstream patch 73852 (2011-03-23) - Add missing return value. (diff)
downloadinkscape-80960b623a99aae1402ab651b2974ef544ed3b03.tar.gz
inkscape-80960b623a99aae1402ab651b2974ef544ed3b03.zip
merged with trunk so I can build again...
(bzr r10092.1.36)
Diffstat (limited to 'src/libgdl')
-rw-r--r--src/libgdl/CMakeLists.txt73
-rw-r--r--src/libgdl/Makefile_insert6
-rw-r--r--src/libgdl/gdl-dock-bar.c891
-rw-r--r--src/libgdl/gdl-dock-bar.h13
-rw-r--r--src/libgdl/gdl-dock-item-button-image.c166
-rw-r--r--src/libgdl/gdl-dock-item-button-image.h70
-rw-r--r--src/libgdl/gdl-dock-item-grip.c780
-rw-r--r--src/libgdl/gdl-dock-item-grip.h45
-rw-r--r--src/libgdl/gdl-dock-item.c702
-rw-r--r--src/libgdl/gdl-dock-item.h64
-rw-r--r--src/libgdl/gdl-dock-master.c41
-rw-r--r--src/libgdl/gdl-dock-master.h21
-rw-r--r--src/libgdl/gdl-dock-notebook.c40
-rw-r--r--src/libgdl/gdl-dock-notebook.h10
-rw-r--r--src/libgdl/gdl-dock-object.c111
-rw-r--r--src/libgdl/gdl-dock-object.h14
-rw-r--r--src/libgdl/gdl-dock-paned.c98
-rw-r--r--src/libgdl/gdl-dock-paned.h10
-rw-r--r--src/libgdl/gdl-dock-placeholder.c63
-rw-r--r--src/libgdl/gdl-dock-placeholder.h12
-rw-r--r--src/libgdl/gdl-dock-tablabel.c108
-rw-r--r--src/libgdl/gdl-dock-tablabel.h10
-rw-r--r--src/libgdl/gdl-dock.c200
-rw-r--r--src/libgdl/gdl-dock.h10
-rw-r--r--src/libgdl/gdl-stock.c127
-rw-r--r--src/libgdl/gdl-switcher.c399
-rw-r--r--src/libgdl/gdl-switcher.h26
-rw-r--r--src/libgdl/gdl-tools.h184
-rw-r--r--src/libgdl/gdl.h (renamed from src/libgdl/gdl-stock.h)31
-rw-r--r--src/libgdl/libgdl.h37
-rw-r--r--src/libgdl/libgdltypebuiltins.h2
31 files changed, 2426 insertions, 1938 deletions
diff --git a/src/libgdl/CMakeLists.txt b/src/libgdl/CMakeLists.txt
index dea93e6bc..3457337e9 100644
--- a/src/libgdl/CMakeLists.txt
+++ b/src/libgdl/CMakeLists.txt
@@ -1,28 +1,49 @@
-IF(WIN32)
-SET(GDL_WIN
-gdl-win32.c
-)
-ENDIF(WIN32)
-SET(libgdl_SRC
-gdl-dock.c
-gdl-dock-bar.c
-gdl-dock-item.c
-gdl-dock-item-grip.c
-gdl-dock-master.c
-gdl-dock-notebook.c
-gdl-dock-object.c
-gdl-dock-paned.c
-gdl-dock-placeholder.c
-gdl-dock-tablabel.c
-gdl-i18n.c
-gdl-stock.c
-gdl-switcher.c
-gdl-tools.h
-libgdlmarshal.c
-libgdltypebuiltins.c
-${GDL_WIN}
+set(libgdl_SRC
+ gdl-dock-bar.c
+ gdl-dock-item-button-image.c
+ gdl-dock-item-grip.c
+ gdl-dock-item.c
+ gdl-dock-master.c
+ gdl-dock-notebook.c
+ gdl-dock-object.c
+ gdl-dock-paned.c
+ gdl-dock-placeholder.c
+ gdl-dock-tablabel.c
+ gdl-dock.c
+ gdl-i18n.c
+ gdl-switcher.c
+ gdl-tools.h
+ libgdlmarshal.c
+ libgdltypebuiltins.c
+
+
+ # -------
+ # Headers
+ gdl-dock-bar.h
+ gdl-dock-item-button-image.h
+ gdl-dock-item-grip.h
+ gdl-dock-item.h
+ gdl-dock-master.h
+ gdl-dock-notebook.h
+ gdl-dock-object.h
+ gdl-dock-paned.h
+ gdl-dock-placeholder.h
+ gdl-dock-tablabel.h
+ gdl-dock.h
+ gdl-i18n.h
+ gdl-stock-icons.h
+ gdl-switcher.h
+ gdl.h
+ libgdlmarshal.h
+ libgdltypebuiltins.h
)
-ADD_LIBRARY(gdl STATIC ${libgdl_SRC})
-TARGET_LINK_LIBRARIES(gdl
-${INKSCAPE_LIBS}) \ No newline at end of file
+
+if(WIN32)
+ list(APPEND libgdl_SRC
+ gdl-win32.c
+ gdl-win32.h
+ )
+endif()
+
+add_inkscape_lib(gdl_LIB "${libgdl_SRC}")
diff --git a/src/libgdl/Makefile_insert b/src/libgdl/Makefile_insert
index 5869633ea..e151fd5d6 100644
--- a/src/libgdl/Makefile_insert
+++ b/src/libgdl/Makefile_insert
@@ -16,7 +16,6 @@ libgdl_libgdl_a_SOURCES = \
libgdl/gdl-dock-tablabel.h \
libgdl/gdl-dock-placeholder.h \
libgdl/gdl-dock-bar.h \
- libgdl/gdl-stock.h \
libgdl/gdl-stock-icons.h \
libgdl/gdl-i18n.h \
libgdl/gdl-i18n.c \
@@ -24,6 +23,8 @@ libgdl_libgdl_a_SOURCES = \
libgdl/gdl-dock-master.c \
libgdl/gdl-dock.c \
libgdl/gdl-dock-item.c \
+ libgdl/gdl-dock-item-button-image.c \
+ libgdl/gdl-dock-item-button-image.h \
libgdl/gdl-dock-item-grip.h \
libgdl/gdl-dock-item-grip.c \
libgdl/gdl-dock-notebook.c \
@@ -31,7 +32,6 @@ libgdl_libgdl_a_SOURCES = \
libgdl/gdl-dock-tablabel.c \
libgdl/gdl-dock-placeholder.c \
libgdl/gdl-dock-bar.c \
- libgdl/gdl-stock.c \
libgdl/gdl-switcher.h \
libgdl/gdl-switcher.c \
libgdl/gdl-win32.h \
@@ -40,4 +40,4 @@ libgdl_libgdl_a_SOURCES = \
libgdl/libgdltypebuiltins.c \
libgdl/libgdlmarshal.h \
libgdl/libgdlmarshal.c \
- libgdl/libgdl.h
+ libgdl/gdl.h
diff --git a/src/libgdl/gdl-dock-bar.c b/src/libgdl/gdl-dock-bar.c
index c4882e7ad..f742a2d73 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,
@@ -65,14 +63,13 @@ static void gdl_dock_bar_remove_item (GdlDockBar *dockbar,
struct _GdlDockBarPrivate {
GdlDockMaster *master;
GSList *items;
- GtkTooltips *tooltips;
GtkOrientation orientation;
GdlDockBarStyle dockbar_style;
};
/* ----- 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 );
@@ -125,16 +122,13 @@ 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;
dockbar->_priv->items = NULL;
- dockbar->_priv->tooltips = gtk_tooltips_new ();
dockbar->_priv->orientation = GTK_ORIENTATION_VERTICAL;
dockbar->_priv->dockbar_style = GDL_DOCK_BAR_BOTH;
- g_object_ref (dockbar->_priv->tooltips);
- gtk_object_sink (GTK_OBJECT (dockbar->_priv->tooltips));
}
static void
@@ -208,17 +202,12 @@ gdl_dock_bar_destroy (GtkObject *object)
priv->master = NULL;
}
- if (priv->tooltips) {
- g_object_unref (priv->tooltips);
- priv->tooltips = NULL;
- }
-
dockbar->_priv = NULL;
g_free (priv);
}
- GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
+ GTK_OBJECT_CLASS (gdl_dock_bar_parent_class)->destroy (object);
}
static void
@@ -255,6 +244,7 @@ gdl_dock_bar_item_clicked (GtkWidget *button,
{
GdlDockBar *dockbar;
GdlDockObject *controller;
+ (void)button;
g_return_if_fail (item != NULL);
@@ -310,7 +300,7 @@ gdl_dock_bar_add_item (GdlDockBar *dockbar,
label = gtk_label_new (name);
if (dockbar->_priv->orientation == GTK_ORIENTATION_VERTICAL)
gtk_label_set_angle (GTK_LABEL (label), 90);
- gtk_box_pack_start_defaults (GTK_BOX (box), label);
+ gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
}
/* FIXME: For now AUTO behaves same as BOTH */
@@ -328,13 +318,13 @@ gdl_dock_bar_add_item (GdlDockBar *dockbar,
image = gtk_image_new_from_stock (GTK_STOCK_NEW,
GTK_ICON_SIZE_SMALL_TOOLBAR);
}
- gtk_box_pack_start_defaults (GTK_BOX (box), image);
+ gtk_box_pack_start (GTK_BOX (box), image, TRUE, TRUE, 0);
}
gtk_container_add (GTK_CONTAINER (button), box);
gtk_box_pack_start (GTK_BOX (dockbar), button, FALSE, FALSE, 0);
- gtk_tooltips_set_tip (priv->tooltips, button, name, name);
+ gtk_widget_set_tooltip_text (button, name);
g_free (name);
g_object_set_data (G_OBJECT (item), "GdlDockBar", dockbar);
@@ -403,6 +393,7 @@ static void
gdl_dock_bar_layout_changed_cb (GdlDockMaster *master,
GdlDockBar *dockbar)
{
+ (void)master;
update_dock_items (dockbar, FALSE);
}
@@ -470,464 +461,548 @@ 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;
+ GtkRequisition child_requisition;
+ GList *child;
+ gint nvis_children;
+ gint height;
+ guint border_width;
+
+ box = GTK_BOX (widget);
+ requisition->width = 0;
+ requisition->height = 0;
+ nvis_children = 0;
+
+
+ for (child = gtk_container_get_children (GTK_CONTAINER (box));
+ child != NULL; child = g_list_next (child))
{
- child = children->data;
- children = children->next;
-
- if (GTK_WIDGET_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;
- }
+ if (gtk_widget_get_visible (GTK_WIDGET (child->data)))
+ {
+ guint padding;
+ gboolean expand;
+ gboolean fill;
+ GtkPackType pack_type;
+
+ gtk_widget_size_request (GTK_WIDGET (child->data), &child_requisition);
+
+ gtk_box_query_child_packing (box,
+ child->data,
+ &expand,
+ &fill,
+ &padding,
+ &pack_type);
+
+ if (gtk_box_get_homogeneous (box))
+ {
+ height = child_requisition.height + padding * 2;
+ requisition->height = MAX (requisition->height, height);
+ }
+ else
+ {
+ requisition->height += child_requisition.height + 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;
+ GList *child;
+ 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;
+
+ for (child = gtk_container_get_children (GTK_CONTAINER (box));
+ child != NULL; child = g_list_next (child))
{
- child = children->data;
- children = children->next;
-
- if (GTK_WIDGET_VISIBLE (child->widget))
- {
- nvis_children += 1;
- if (child->expand)
- nexpand_children += 1;
- }
+ guint padding;
+ gboolean expand;
+ gboolean fill;
+ GtkPackType pack_type;
+
+ gtk_box_query_child_packing (box,
+ child->data,
+ &expand,
+ &fill,
+ &padding,
+ &pack_type);
+ if (gtk_widget_get_visible (GTK_WIDGET(child->data)))
+ {
+ nvis_children += 1;
+ if (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_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_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);
+
+ for (child = gtk_container_get_children (GTK_CONTAINER (box));
+ child != NULL; child = g_list_next (child))
+ {
+ guint padding;
+ gboolean expand;
+ gboolean fill;
+ GtkPackType pack_type;
+
+ gtk_box_query_child_packing (box,
+ child->data,
+ &expand,
+ &fill,
+ &padding,
+ &pack_type);
+
+ if ((pack_type == GTK_PACK_START) && gtk_widget_get_visible (GTK_WIDGET (child->data)))
+ {
+ 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 (GTK_WIDGET (child->data), &child_requisition);
+ child_height = child_requisition.height + padding * 2;
- if (child->expand)
+ if (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 (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 - padding * 2);
+ child_allocation.y = y + 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 (GTK_WIDGET (child->data), &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 (GTK_WIDGET (child->data), &child_allocation);
- y -= (child_height + box->spacing);
- }
- }
- }
-}
+ y += child_height + gtk_box_get_spacing (box);
+ }
+ }
-static void gdl_dock_bar_size_hrequest (GtkWidget *widget,
- 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)
- {
- child = children->data;
- children = children->next;
+ y = allocation->y + allocation->height - border_width;
+
+ for (child = gtk_container_get_children (GTK_CONTAINER (box));
+ child != NULL; child = g_list_next (child))
+ {
+ guint padding;
+ gboolean expand;
+ gboolean fill;
+ GtkPackType pack_type;
+
+ gtk_box_query_child_packing (box,
+ child->data,
+ &expand,
+ &fill,
+ &padding,
+ &pack_type);
+
+ if ((pack_type == GTK_PACK_END) && gtk_widget_get_visible (GTK_WIDGET (child->data)))
+ {
+ GtkRequisition child_requisition;
+ gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &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 + padding * 2;
- if (GTK_WIDGET_VISIBLE (child->widget))
- {
- GtkRequisition child_requisition;
+ if (expand)
+ {
+ if (nexpand_children == 1)
+ child_height += height;
+ else
+ child_height += extra;
- gtk_widget_size_request (child->widget, &child_requisition);
+ nexpand_children -= 1;
+ height -= extra;
+ }
+ }
- 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 (fill)
+ {
+ child_allocation.height = MAX (1, child_height - padding * 2);
+ child_allocation.y = y + padding - child_height;
+ }
+ else
+ {
+ child_allocation.height = child_requisition.height;
+ child_allocation.y = y + (child_height - child_allocation.height) / 2 - child_height;
+ }
- requisition->height = MAX (requisition->height, child_requisition.height);
+ gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation);
- nvis_children += 1;
- }
+ y -= (child_height + gtk_box_get_spacing (box));
+ }
+ }
}
+}
- if (nvis_children > 0)
+static void gdl_dock_bar_size_hrequest (GtkWidget *widget,
+ GtkRequisition *requisition )
+{
+ GtkBox *box;
+ GList *child;
+ gint nvis_children;
+ gint width;
+ guint border_width;
+
+ box = GTK_BOX (widget);
+ requisition->width = 0;
+ requisition->height = 0;
+ nvis_children = 0;
+
+ for (child = gtk_container_get_children (GTK_CONTAINER (box));
+ child != NULL; child = g_list_next (child))
{
- if (box->homogeneous)
- requisition->width *= nvis_children;
- requisition->width += (nvis_children - 1) * box->spacing;
+ guint padding;
+ gboolean expand;
+ gboolean fill;
+ GtkPackType pack_type;
+
+ gtk_box_query_child_packing (box,
+ child->data,
+ &expand,
+ &fill,
+ &padding,
+ &pack_type);
+
+
+ if (gtk_widget_get_visible (GTK_WIDGET (child->data)))
+ {
+ GtkRequisition child_requisition;
+
+ gtk_widget_size_request (GTK_WIDGET (child->data), &child_requisition);
+
+ if (gtk_box_get_homogeneous (box))
+ {
+ width = child_requisition.width + padding * 2;
+ requisition->width = MAX (requisition->width, width);
+ }
+ else
+ {
+ requisition->width += child_requisition.width + padding * 2;
+ }
+
+ requisition->height = MAX (requisition->height, child_requisition.height);
+
+ nvis_children += 1;
+ }
}
- requisition->width += GTK_CONTAINER (box)->border_width * 2;
- requisition->height += GTK_CONTAINER (box)->border_width * 2;
+ if (nvis_children > 0)
+ {
+ if (gtk_box_get_homogeneous (box))
+ requisition->width *= nvis_children;
+ requisition->width += (nvis_children - 1) * gtk_box_get_spacing (box);
+ }
+
+ 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;
+ GList *child;
+ 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;
+
+ for (child = gtk_container_get_children (GTK_CONTAINER (box));
+ child != NULL; child = g_list_next (child))
{
- child = children->data;
- children = children->next;
-
- if (GTK_WIDGET_VISIBLE (child->widget))
- {
- nvis_children += 1;
- if (child->expand)
- nexpand_children += 1;
- }
+ guint padding;
+ gboolean expand;
+ gboolean fill;
+ GtkPackType pack_type;
+
+ gtk_box_query_child_packing (box,
+ child->data,
+ &expand,
+ &fill,
+ &padding,
+ &pack_type);
+
+ if (gtk_widget_get_visible (GTK_WIDGET (child->data)))
+ {
+ nvis_children += 1;
+ if (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_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_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);
+
+ for (child = gtk_container_get_children (GTK_CONTAINER (box));
+ child != NULL; child = g_list_next (child))
+ {
+ guint padding;
+ gboolean expand;
+ gboolean fill;
+ GtkPackType pack_type;
+
+ gtk_box_query_child_packing (box,
+ child->data,
+ &expand,
+ &fill,
+ &padding,
+ &pack_type);
+
+ if ((pack_type == GTK_PACK_START) && gtk_widget_get_visible (GTK_WIDGET (child->data)))
+ {
+ if (gtk_box_get_homogeneous (box))
+ {
+ 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 (GTK_WIDGET (child->data), &child_requisition);
+
+ child_width = child_requisition.width + padding * 2;
+
+ if (expand)
+ {
+ if (nexpand_children == 1)
+ child_width += width;
+ else
+ child_width += extra;
+
+ nexpand_children -= 1;
+ width -= extra;
+ }
+ }
+
+ if (fill)
+ {
+ child_allocation.width = MAX (1, child_width - padding * 2);
+ child_allocation.x = x + padding;
+ }
+ else
{
- if (nvis_children == 1)
- child_width = width;
- else
- child_width = extra;
+ GtkRequisition child_requisition;
- nvis_children -= 1;
- width -= extra;
+ gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
+ child_allocation.width = child_requisition.width;
+ child_allocation.x = x + (child_width - child_allocation.width) / 2;
}
- else
+
+ 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 (GTK_WIDGET (child->data), &child_allocation);
+
+ x += child_width + gtk_box_get_spacing (box);
+ }
+ }
+
+ x = allocation->x + allocation->width - border_width;
+
+ for (child = gtk_container_get_children (GTK_CONTAINER (box));
+ child != NULL; child = g_list_next (child))
+ {
+ guint padding;
+ gboolean expand;
+ gboolean fill;
+ GtkPackType pack_type;
+
+ gtk_box_query_child_packing (box,
+ child->data,
+ &expand,
+ &fill,
+ &padding,
+ &pack_type);
+
+ if ((pack_type == GTK_PACK_END) && gtk_widget_get_visible (GTK_WIDGET (child->data)))
+ {
+ GtkRequisition child_requisition;
+ gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition);
+
+ if (gtk_box_get_homogeneous (box))
{
- child_width = child_requisition.width + child->padding * 2;
+ if (nvis_children == 1)
+ child_width = width;
+ else
+ child_width = extra;
- if (child->expand)
+ nvis_children -= 1;
+ width -= extra;
+ }
+ else
+ {
+ child_width = child_requisition.width + padding * 2;
+
+ if (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 (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, child_width - padding * 2);
+ child_allocation.x = x + padding - child_width;
}
- else
+ else
{
- child_allocation.width = child_requisition.width;
- child_allocation.x = x + (child_width - child_allocation.width) / 2 - child_width;
+ 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;
+ 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 (GTK_WIDGET (child->data), &child_allocation);
- x -= (child_width + box->spacing);
- }
- }
+ x -= (child_width + gtk_box_get_spacing (box));
+ }
+ }
}
}
diff --git a/src/libgdl/gdl-dock-bar.h b/src/libgdl/gdl-dock-bar.h
index 22b99edd4..ca6da1d26 100644
--- a/src/libgdl/gdl-dock-bar.h
+++ b/src/libgdl/gdl-dock-bar.h
@@ -22,18 +22,17 @@
#ifndef __GDL_DOCK_BAR_H__
#define __GDL_DOCK_BAR_H__
-#include <gtk/gtkvbox.h>
-#include "libgdl/gdl-dock.h"
+#include <gtk/gtk.h>
G_BEGIN_DECLS
/* standard macros */
#define GDL_TYPE_DOCK_BAR (gdl_dock_bar_get_type ())
-#define GDL_DOCK_BAR(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_BAR, GdlDockBar))
-#define GDL_DOCK_BAR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_BAR, GdlDockBarClass))
-#define GDL_IS_DOCK_BAR(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_BAR))
-#define GDL_IS_DOCK_BAR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_BAR))
-#define GDL_DOCK_BAR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_BAR, GdlDockBarClass))
+#define GDL_DOCK_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_BAR, GdlDockBar))
+#define GDL_DOCK_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_BAR, GdlDockBarClass))
+#define GDL_IS_DOCK_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_BAR))
+#define GDL_IS_DOCK_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_BAR))
+#define GDL_DOCK_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_BAR, GdlDockBarClass))
/* data types & structures */
typedef struct _GdlDockBar GdlDockBar;
diff --git a/src/libgdl/gdl-dock-item-button-image.c b/src/libgdl/gdl-dock-item-button-image.c
new file mode 100644
index 000000000..31613a898
--- /dev/null
+++ b/src/libgdl/gdl-dock-item-button-image.c
@@ -0,0 +1,166 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * gdl-dock-item-button-image.c
+ *
+ * Author: Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "gdl-dock-item-button-image.h"
+
+#include <math.h>
+
+#define ICON_SIZE 12
+
+G_DEFINE_TYPE (GdlDockItemButtonImage,
+ gdl_dock_item_button_image,
+ GTK_TYPE_WIDGET);
+
+static gint
+gdl_dock_item_button_image_expose (GtkWidget *widget,
+ GdkEventExpose *event)
+{
+ GdlDockItemButtonImage *button_image;
+ GtkStyle *style;
+ GdkColor *color;
+
+ g_return_val_if_fail (widget != NULL, 0);
+ button_image = GDL_DOCK_ITEM_BUTTON_IMAGE (widget);
+
+ cairo_t *cr = gdk_cairo_create (event->window);
+ cairo_translate (cr, event->area.x, event->area.y);
+
+ /* Set up the pen */
+ cairo_set_line_width(cr, 1.0);
+
+ style = gtk_widget_get_style (widget);
+ g_return_val_if_fail (style != NULL, 0);
+ color = &style->fg[GTK_STATE_NORMAL];
+ cairo_set_source_rgba(cr, color->red / 65535.0,
+ color->green / 65535.0, color->blue / 65535.0, 0.55);
+
+ /* Draw the icon border */
+ cairo_move_to (cr, 10.5, 2.5);
+ cairo_arc (cr, 10.5, 4.5, 2, -0.5 * M_PI, 0);
+ cairo_line_to (cr, 12.5, 10.5);
+ cairo_arc (cr, 10.5, 10.5, 2, 0, 0.5 * M_PI);
+ cairo_line_to (cr, 4.5, 12.5);
+ cairo_arc (cr, 4.5, 10.5, 2, 0.5 * M_PI, M_PI);
+ cairo_line_to (cr, 2.5, 4.5);
+ cairo_arc (cr, 4.5, 4.5, 2, M_PI, 1.5 * M_PI);
+ cairo_close_path (cr);
+
+ cairo_stroke (cr);
+
+ /* Draw the icon */
+ cairo_new_path (cr);
+
+ switch(button_image->image_type) {
+ case GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE:
+ cairo_move_to (cr, 4.0, 5.5);
+ cairo_line_to (cr, 4.0, 5.5);
+ cairo_line_to (cr, 6.0, 7.5);
+ cairo_line_to (cr, 4.0, 9.5);
+ cairo_line_to (cr, 5.5, 11.0);
+ cairo_line_to (cr, 7.5, 9.0);
+ cairo_line_to (cr, 9.5, 11.0);
+ cairo_line_to (cr, 11.0, 9.5);
+ cairo_line_to (cr, 9.0, 7.5);
+ cairo_line_to (cr, 11.0, 5.5);
+ cairo_line_to (cr, 9.5, 4.0);
+ cairo_line_to (cr, 7.5, 6.0);
+ cairo_line_to (cr, 5.5, 4.0);
+ cairo_close_path (cr);
+ break;
+
+ case GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY:
+ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
+ cairo_move_to (cr, 4.5, 7.5);
+ cairo_line_to (cr, 10.0, 4.75);
+ cairo_line_to (cr, 10.0, 10.25);
+ cairo_close_path (cr);
+ } else {
+ cairo_move_to (cr, 10.5, 7.5);
+ cairo_line_to (cr, 5, 4.75);
+ cairo_line_to (cr, 5, 10.25);
+ cairo_close_path (cr);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ cairo_fill (cr);
+
+ /* Finish up */
+ cairo_destroy (cr);
+
+ return 0;
+}
+
+static void
+gdl_dock_item_button_image_init (
+ GdlDockItemButtonImage *button_image)
+{
+ gtk_widget_set_has_window (GTK_WIDGET (button_image), FALSE);
+}
+
+static void
+gdl_dock_item_button_image_size_request (GtkWidget *widget,
+ GtkRequisition *requisition)
+{
+ g_return_if_fail (GDL_IS_DOCK_ITEM_BUTTON_IMAGE (widget));
+ g_return_if_fail (requisition != NULL);
+
+ requisition->width = ICON_SIZE;
+ requisition->height = ICON_SIZE;
+}
+
+static void
+gdl_dock_item_button_image_class_init (
+ GdlDockItemButtonImageClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ widget_class->expose_event =
+ gdl_dock_item_button_image_expose;
+ widget_class->size_request =
+ gdl_dock_item_button_image_size_request;
+}
+
+/* ----- Public interface ----- */
+
+/**
+ * gdl_dock_item_button_image_new:
+ * @image_type: Specifies what type of image the widget should
+ * display
+ *
+ * Creates a new GDL dock button image object.
+ * Returns: The newly created dock item button image widget.
+ **/
+GtkWidget*
+gdl_dock_item_button_image_new (GdlDockItemButtonImageType image_type)
+{
+ GdlDockItemButtonImage *button_image = g_object_new (
+ GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, NULL);
+ button_image->image_type = image_type;
+
+ return GTK_WIDGET (button_image);
+}
diff --git a/src/libgdl/gdl-dock-item-button-image.h b/src/libgdl/gdl-dock-item-button-image.h
new file mode 100644
index 000000000..ce0c6faaf
--- /dev/null
+++ b/src/libgdl/gdl-dock-item-button-image.h
@@ -0,0 +1,70 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * gdl-dock-item-button-image.h
+ *
+ * Author: Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _GDL_DOCK_ITEM_BUTTON_IMAGE_H_
+#define _GDL_DOCK_ITEM_BUTTON_IMAGE_H_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+/* Standard Macros */
+#define GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE \
+ (gdl_dock_item_button_image_get_type())
+#define GDL_DOCK_ITEM_BUTTON_IMAGE(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImage))
+#define GDL_DOCK_ITEM_BUTTON_IMAGE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImageClass))
+#define GDL_IS_DOCK_ITEM_BUTTON_IMAGE(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE))
+#define GDL_IS_DOCK_ITEM_BUTTON_IMAGE_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE))
+#define GDL_DOCK_ITEM_BUTTON_IMAGE_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImageClass))
+
+/* Data Types & Structures */
+typedef enum {
+ GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE,
+ GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY
+} GdlDockItemButtonImageType;
+
+typedef struct _GdlDockItemButtonImage GdlDockItemButtonImage;
+typedef struct _GdlDockItemButtonImageClass GdlDockItemButtonImageClass;
+
+struct _GdlDockItemButtonImage {
+ GtkWidget parent;
+
+ GdlDockItemButtonImageType image_type;
+};
+
+struct _GdlDockItemButtonImageClass {
+ GtkWidgetClass parent_class;
+};
+
+/* Data Public Functions */
+GType gdl_dock_item_button_image_get_type (void);
+GtkWidget *gdl_dock_item_button_image_new (
+ GdlDockItemButtonImageType image_type);
+
+G_END_DECLS
+
+#endif /* _GDL_DOCK_ITEM_BUTTON_IMAGE_H_ */
diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c
index 86e7bc14c..b7c3d0f5b 100644
--- a/src/libgdl/gdl-dock-item-grip.c
+++ b/src/libgdl/gdl-dock-item-grip.c
@@ -1,13 +1,30 @@
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
-/**
+/*
* gdl-dock-item-grip.c
*
- * Based on bonobo-dock-item-grip. Original copyright notice follows.
+ * Author: Michael Meeks Copyright (C) 2002 Sun Microsystems, Inc.
+ *
+ * Based on BonoboDockItemGrip. Original copyright notice follows.
+ *
+ * Copyright (C) 1998 Ettore Perazzoli
+ * Copyright (C) 1998 Elliot Lee
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * All rights reserved.
*
- * Author:
- * Michael Meeks
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * Copyright (C) 2002 Sun Microsystems, Inc.
+ * 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
@@ -17,15 +34,14 @@
#include "gdl-i18n.h"
#include <string.h>
#include <glib-object.h>
-#include <gtk/gtkbutton.h>
-#include <gtk/gtktooltips.h>
-#include <gtk/gtkimage.h>
+#include <gtk/gtk.h>
#include "gdl-dock-item.h"
#include "gdl-dock-item-grip.h"
-#include "gdl-stock.h"
-#include "gdl-tools.h"
+#include "gdl-dock-item-button-image.h"
+#include "gdl-switcher.h"
#define ALIGN_BORDER 5
+#define DRAG_HANDLE_SIZE 10
enum {
PROP_0,
@@ -33,169 +49,108 @@ enum {
};
struct _GdlDockItemGripPrivate {
+ GtkWidget *label;
+
GtkWidget *close_button;
GtkWidget *iconify_button;
- GtkTooltips *tooltips;
-
- gboolean icon_pixbuf_valid;
- GdkPixbuf *icon_pixbuf;
-
- gchar *title;
- PangoLayout *title_layout;
+
+ gboolean handle_shown;
};
-GDL_CLASS_BOILERPLATE (GdlDockItemGrip, gdl_dock_item_grip,
- GtkContainer, GTK_TYPE_CONTAINER);
-
-/* must be called after size_allocate */
-static void
-gdl_dock_item_grip_get_title_area (GdlDockItemGrip *grip,
- GdkRectangle *area)
+G_DEFINE_TYPE (GdlDockItemGrip, gdl_dock_item_grip, GTK_TYPE_CONTAINER);
+
+GtkWidget*
+gdl_dock_item_create_label_widget(GdlDockItemGrip *grip)
{
- GtkWidget *widget = GTK_WIDGET (grip);
- gint border = GTK_CONTAINER (grip)->border_width;
- gint alloc_height;
-
- area->width = (widget->allocation.width - 2 * border - ALIGN_BORDER);
-
- pango_layout_get_pixel_size (grip->_priv->title_layout, NULL, &alloc_height);
-
- alloc_height = MAX (grip->_priv->close_button->allocation.height, alloc_height);
- alloc_height = MAX (grip->_priv->iconify_button->allocation.height, alloc_height);
- if (GTK_WIDGET_VISIBLE (grip->_priv->close_button)) {
- area->width -= grip->_priv->close_button->allocation.width;
- }
- if (GTK_WIDGET_VISIBLE (grip->_priv->iconify_button)) {
- area->width -= grip->_priv->iconify_button->allocation.width;
- }
-
- area->x = widget->allocation.x + border + ALIGN_BORDER;
- area->y = widget->allocation.y + border;
- area->height = alloc_height;
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- area->x += (widget->allocation.width - 2 * border) - area->width;
-}
-
-static void
-ensure_title_and_icon_pixbuf (GdlDockItemGrip *grip)
-{
- gchar *stock_id;
+ GtkHBox *label_box;
+ GtkImage *image;
+ GtkLabel *label;
+ gchar *stock_id = NULL;
+ gchar *title = NULL;
GdkPixbuf *pixbuf;
+
+ label_box = (GtkHBox*)gtk_hbox_new (FALSE, 0);
- g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (grip));
-
- /* get long name property from the dock object */
- if (!grip->_priv->title) {
- g_object_get (G_OBJECT (grip->item), "long-name", &grip->_priv->title, NULL);
- if (!grip->_priv->title)
- grip->_priv->title = g_strdup ("");
- }
-
- /* retrieve stock pixbuf, if any */
- if (!grip->_priv->icon_pixbuf_valid) {
- g_object_get (G_OBJECT (grip->item), "stock-id", &stock_id, NULL);
+ g_object_get (G_OBJECT (grip->item), "stock-id", &stock_id, NULL);
+ g_object_get (G_OBJECT (grip->item), "pixbuf-icon", &pixbuf, NULL);
+ if(stock_id) {
+ image = GTK_IMAGE(gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU));
- if (stock_id) {
- grip->_priv->icon_pixbuf = gtk_widget_render_icon (GTK_WIDGET (grip),
- stock_id,
- GTK_ICON_SIZE_MENU, "");
- g_free (stock_id);
- grip->_priv->icon_pixbuf_valid = TRUE;
- }
+ gtk_widget_show (GTK_WIDGET(image));
+ gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(image), FALSE, TRUE, 0);
+
+ g_free (stock_id);
+ }
+ else if (pixbuf) {
+ image = GTK_IMAGE(gtk_image_new_from_pixbuf (pixbuf));
+
+ gtk_widget_show (GTK_WIDGET(image));
+ gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(image), FALSE, TRUE, 0);
}
-
- /* retrieve pixbuf icon, if any */
- if (!grip->_priv->icon_pixbuf_valid) {
- g_object_get (G_OBJECT (grip->item), "pixbuf-icon", &pixbuf, NULL);
- if (pixbuf) {
- grip->_priv->icon_pixbuf = pixbuf;
- grip->_priv->icon_pixbuf_valid = TRUE;
+ g_object_get (G_OBJECT (grip->item), "long-name", &title, NULL);
+ if (title) {
+ label = GTK_LABEL(gtk_label_new(title));
+ gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END);
+ gtk_label_set_justify(label, GTK_JUSTIFY_LEFT);
+ gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
+ gtk_widget_show (GTK_WIDGET(label));
+
+ if (gtk_widget_get_direction (GTK_WIDGET(grip)) == GTK_TEXT_DIR_RTL) {
+ gtk_box_pack_end(GTK_BOX(label_box), GTK_WIDGET(label), TRUE, TRUE, 1);
+ } else {
+ gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(label), TRUE, TRUE, 1);
}
+
+ g_free(title);
}
-
- /* create layout: the actual text is reset at size_allocate */
- if (!grip->_priv->title_layout) {
- grip->_priv->title_layout = gtk_widget_create_pango_layout (GTK_WIDGET (grip),
- grip->_priv->title);
- pango_layout_set_single_paragraph_mode (grip->_priv->title_layout, TRUE);
- }
+
+ return GTK_WIDGET(label_box);
}
static gint
gdl_dock_item_grip_expose (GtkWidget *widget,
- GdkEventExpose *event)
+ GdkEventExpose *event)
{
GdlDockItemGrip *grip;
- GdkRectangle title_area;
- GdkRectangle expose_area;
- GtkStyle *bg_style;
- gint layout_width;
- gint layout_height;
- gint text_x;
- gint text_y;
- gboolean item_or_child_has_focus;
+ GtkAllocation allocation;
+ GdkRectangle handle_area;
+ GdkRectangle expose_area;
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;
-
- pixbuf_rect.width = gdk_pixbuf_get_width (grip->_priv->icon_pixbuf);
- pixbuf_rect.height = gdk_pixbuf_get_height (grip->_priv->icon_pixbuf);
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) {
- pixbuf_rect.x = title_area.x + title_area.width - pixbuf_rect.width;
+ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
+ handle_area.x = allocation.x;
+ handle_area.y = allocation.y;
+ handle_area.width = DRAG_HANDLE_SIZE;
+ handle_area.height = allocation.height;
} else {
- pixbuf_rect.x = title_area.x;
- title_area.x += pixbuf_rect.width + 1;
+ handle_area.x = allocation.x + allocation.width - DRAG_HANDLE_SIZE;
+ handle_area.y = allocation.y;
+ handle_area.width = DRAG_HANDLE_SIZE;
+ handle_area.height = allocation.height;
}
- /* shrink title area by the pixbuf width plus a 1px spacing */
- title_area.width -= pixbuf_rect.width + 1;
- pixbuf_rect.y = title_area.y + (title_area.height - pixbuf_rect.height) / 2;
-
- if (gdk_rectangle_intersect (&event->area, &pixbuf_rect, &expose_area)) {
- GdkGC *gc;
- GtkStyle *style;
-
- style = gtk_widget_get_style (widget);
- gc = style->bg_gc[widget->state];
- gdk_draw_pixbuf (GDK_DRAWABLE (widget->window), gc,
- grip->_priv->icon_pixbuf,
- 0, 0, pixbuf_rect.x, pixbuf_rect.y,
- pixbuf_rect.width, pixbuf_rect.height,
- GDK_RGB_DITHER_NONE, 0, 0);
- }
- }
-
- if (gdk_rectangle_intersect (&title_area, &event->area, &expose_area)) {
- pango_layout_get_pixel_size (grip->_priv->title_layout, &layout_width,
- &layout_height);
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- text_x = title_area.x + title_area.width - layout_width;
- else
- text_x = title_area.x;
-
- text_y = title_area.y + (title_area.height - layout_height) / 2;
+ if (gdk_rectangle_intersect (&handle_area, &event->area, &expose_area)) {
- gtk_paint_layout (widget->style, widget->window, widget->state, TRUE,
- &expose_area, widget, NULL, text_x, text_y,
- grip->_priv->title_layout);
+ 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,
+ GTK_ORIENTATION_VERTICAL);
+
+ }
+
}
- 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
gdl_dock_item_grip_item_notify (GObject *master,
@@ -204,32 +159,24 @@ gdl_dock_item_grip_item_notify (GObject *master,
{
GdlDockItemGrip *grip;
gboolean cursor;
+ (void)master;
grip = GDL_DOCK_ITEM_GRIP (data);
- if (strcmp (pspec->name, "stock-id") == 0) {
- if (grip->_priv->icon_pixbuf) {
- g_object_unref (grip->_priv->icon_pixbuf);
- grip->_priv->icon_pixbuf = NULL;
- }
- grip->_priv->icon_pixbuf_valid = FALSE;
- ensure_title_and_icon_pixbuf (grip);
-
- } else if (strcmp (pspec->name, "long-name") == 0) {
- g_free (grip->_priv->title);
- g_object_unref (grip->_priv->title_layout);
- grip->_priv->title_layout = NULL;
- grip->_priv->title = NULL;
- ensure_title_and_icon_pixbuf (grip);
- gtk_widget_queue_draw (GTK_WIDGET (grip));
+ if ((strcmp (pspec->name, "stock-id") == 0) ||
+ (strcmp (pspec->name, "long-name") == 0)) {
+
+ gdl_dock_item_grip_set_label (grip,
+ gdl_dock_item_create_label_widget(grip));
+
} else if (strcmp (pspec->name, "behavior") == 0) {
- cursor = FALSE;
+ cursor = FALSE;
if (grip->_priv->close_button) {
if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item)) {
gtk_widget_hide (GTK_WIDGET (grip->_priv->close_button));
} else {
gtk_widget_show (GTK_WIDGET (grip->_priv->close_button));
- cursor = TRUE;
+ cursor = TRUE;
}
}
if (grip->_priv->iconify_button) {
@@ -237,10 +184,10 @@ gdl_dock_item_grip_item_notify (GObject *master,
gtk_widget_hide (GTK_WIDGET (grip->_priv->iconify_button));
} else {
gtk_widget_show (GTK_WIDGET (grip->_priv->iconify_button));
- cursor = TRUE;
+ cursor = TRUE;
}
}
- if (grip->title_window && !cursor)
+ if (grip->title_window && !cursor)
gdk_window_set_cursor (grip->title_window, NULL);
}
@@ -250,25 +197,13 @@ static void
gdl_dock_item_grip_destroy (GtkObject *object)
{
GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (object);
-
+
if (grip->_priv) {
GdlDockItemGripPrivate *priv = grip->_priv;
- if (priv->title_layout) {
- g_object_unref (priv->title_layout);
- priv->title_layout = NULL;
- }
- g_free (priv->title);
- priv->title = NULL;
-
- if (priv->icon_pixbuf) {
- g_object_unref (priv->icon_pixbuf);
- priv->icon_pixbuf = NULL;
- }
-
- if (priv->tooltips) {
- g_object_unref (priv->tooltips);
- priv->tooltips = NULL;
+ if (priv->label) {
+ gtk_widget_unparent(grip->_priv->label);
+ priv->label = NULL;
}
if (grip->item)
@@ -280,8 +215,8 @@ gdl_dock_item_grip_destroy (GtkObject *object)
grip->_priv = NULL;
g_free (priv);
}
-
- GDL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
+
+ GTK_OBJECT_CLASS (gdl_dock_item_grip_parent_class)->destroy (object);
}
static void
@@ -300,15 +235,15 @@ gdl_dock_item_grip_set_property (GObject *object,
case PROP_ITEM:
grip->item = g_value_get_object (value);
if (grip->item) {
- g_signal_connect (grip->item, "notify::long_name",
+ g_signal_connect (grip->item, "notify::long-name",
G_CALLBACK (gdl_dock_item_grip_item_notify),
grip);
- g_signal_connect (grip->item, "notify::stock_id",
+ g_signal_connect (grip->item, "notify::stock-id",
+ G_CALLBACK (gdl_dock_item_grip_item_notify),
+ grip);
+ g_signal_connect (grip->item, "notify::behavior",
G_CALLBACK (gdl_dock_item_grip_item_notify),
grip);
- g_signal_connect (grip->item, "notify::behavior",
- G_CALLBACK (gdl_dock_item_grip_item_notify),
- grip);
if (!GDL_DOCK_ITEM_CANT_CLOSE (grip->item) && grip->_priv->close_button)
gtk_widget_show (grip->_priv->close_button);
@@ -326,75 +261,141 @@ static void
gdl_dock_item_grip_close_clicked (GtkWidget *widget,
GdlDockItemGrip *grip)
{
+ (void)widget;
g_return_if_fail (grip->item != NULL);
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;
+ gboolean ev_ret;
+
+ g_return_if_fail (gtk_widget_get_realized (iconify_button));
+
+ window = gtk_widget_get_parent_window (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_BUTTON (iconify_button)->in_button = FALSE;
+ g_signal_emit_by_name (iconify_button, "leave-notify-event",
+ event, &ev_ret, 0);
+
+ gdk_event_free (event);
+}
+
static void
gdl_dock_item_grip_iconify_clicked (GtkWidget *widget,
GdlDockItemGrip *grip)
{
+ GtkWidget *parent;
+
+ (void)widget;
g_return_if_fail (grip->item != NULL);
- 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));
+ gdl_dock_item_grip_fix_iconify_button (grip);
+
+ parent = gtk_widget_get_parent (GTK_WIDGET (grip->item));
+ if (GDL_IS_SWITCHER (parent))
+ {
+ /* Note: We can not use gtk_container_foreach (parent) here because
+ * during iconificatoin, the internal children changes in parent.
+ * Instead we keep a list of items to iconify and iconify them
+ * one by one.
+ */
+ GList *node;
+ GList *items =
+ gtk_container_get_children (GTK_CONTAINER (parent));
+ for (node = items; node != NULL; node = node->next)
+ {
+ GdlDockItem *item = GDL_DOCK_ITEM (node->data);
+ if (!GDL_DOCK_ITEM_CANT_ICONIFY (item))
+ gdl_dock_item_iconify_item (item);
+ }
+ g_list_free (items);
+ }
+ else
+ {
+ gdl_dock_item_iconify_item (grip->item);
+ }
}
static void
-gdl_dock_item_grip_instance_init (GdlDockItemGrip *grip)
+gdl_dock_item_grip_init (GdlDockItemGrip *grip)
{
GtkWidget *image;
- GTK_WIDGET_SET_FLAGS (grip, GTK_NO_WINDOW);
+ gtk_widget_set_has_window (GTK_WIDGET (grip), FALSE);
grip->_priv = g_new0 (GdlDockItemGripPrivate, 1);
- grip->_priv->icon_pixbuf_valid = FALSE;
- grip->_priv->icon_pixbuf = NULL;
- grip->_priv->title_layout = NULL;
-
+ grip->_priv->label = NULL;
+ grip->_priv->handle_shown = FALSE;
+
+ /* create the close button */
gtk_widget_push_composite_child ();
grip->_priv->close_button = gtk_button_new ();
gtk_widget_pop_composite_child ();
-
- GTK_WIDGET_UNSET_FLAGS (grip->_priv->close_button, GTK_CAN_FOCUS);
+
+ gtk_widget_set_can_focus (grip->_priv->close_button, FALSE);
gtk_widget_set_parent (grip->_priv->close_button, GTK_WIDGET (grip));
gtk_button_set_relief (GTK_BUTTON (grip->_priv->close_button), GTK_RELIEF_NONE);
gtk_widget_show (grip->_priv->close_button);
- image = gtk_image_new_from_stock (GDL_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
+ image = gdl_dock_item_button_image_new(GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE);
gtk_container_add (GTK_CONTAINER (grip->_priv->close_button), image);
gtk_widget_show (image);
g_signal_connect (G_OBJECT (grip->_priv->close_button), "clicked",
G_CALLBACK (gdl_dock_item_grip_close_clicked), grip);
+ /* create the iconify button */
gtk_widget_push_composite_child ();
grip->_priv->iconify_button = gtk_button_new ();
gtk_widget_pop_composite_child ();
-
- GTK_WIDGET_UNSET_FLAGS (grip->_priv->iconify_button, GTK_CAN_FOCUS);
+
+ gtk_widget_set_can_focus (grip->_priv->iconify_button, FALSE);
gtk_widget_set_parent (grip->_priv->iconify_button, GTK_WIDGET (grip));
gtk_button_set_relief (GTK_BUTTON (grip->_priv->iconify_button), GTK_RELIEF_NONE);
gtk_widget_show (grip->_priv->iconify_button);
- image = gtk_image_new_from_stock (GDL_STOCK_MENU_RIGHT, GTK_ICON_SIZE_MENU);
+ image = gdl_dock_item_button_image_new(GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY);
gtk_container_add (GTK_CONTAINER (grip->_priv->iconify_button), image);
gtk_widget_show (image);
g_signal_connect (G_OBJECT (grip->_priv->iconify_button), "clicked",
G_CALLBACK (gdl_dock_item_grip_iconify_clicked), grip);
- grip->_priv->tooltips = gtk_tooltips_new ();
- g_object_ref (grip->_priv->tooltips);
- gtk_object_sink (GTK_OBJECT (grip->_priv->tooltips));
- gtk_tooltips_set_tip (grip->_priv->tooltips, grip->_priv->iconify_button,
- _("Iconify"), _("Iconify this dock"));
- gtk_tooltips_set_tip (grip->_priv->tooltips, grip->_priv->close_button,
- _("Close"), _("Close this dock"));
+ /* set tooltips on the buttons */
+ gtk_widget_set_tooltip_text (grip->_priv->iconify_button,
+ _("Iconify this dock"));
+ gtk_widget_set_tooltip_text (grip->_priv->close_button,
+ _("Close this dock"));
}
static void
@@ -402,45 +403,50 @@ 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;
- GdkRectangle area;
GdkCursor *cursor;
- ensure_title_and_icon_pixbuf (grip);
- gdl_dock_item_grip_get_title_area (grip, &area);
-
- attributes.x = area.x;
- attributes.y = area.y;
- attributes.width = area.width;
- attributes.height = area.height;
- attributes.window_type = GDK_WINDOW_TEMP;
- attributes.wclass = GDK_INPUT_ONLY;
- attributes.override_redirect = TRUE;
- attributes.event_mask = (GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_BUTTON_MOTION_MASK |
- gtk_widget_get_events (widget));
+ g_return_if_fail (grip->_priv->label != NULL);
+
+ 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;
grip->title_window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes,
- (GDK_WA_X |
- GDK_WA_Y |
- GDK_WA_NOREDIR));
+ &attributes, (GDK_WA_X | GDK_WA_Y));
- gdk_window_set_user_data (grip->title_window, widget);
+ gdk_window_set_user_data (grip->title_window, grip);
+
+ /* Unref the ref from parent realize for NO_WINDOW */
+ g_object_unref (gtk_widget_get_window (widget));
+
+ /* Need to ref widget->window, because parent unrealize unrefs it */
+ 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);
- if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item))
- cursor = NULL;
- else if (GDL_DOCK_ITEM_CANT_ICONIFY (grip->item))
- cursor = NULL;
- else
- cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
+ if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item) &&
+ GDL_DOCK_ITEM_CANT_ICONIFY (grip->item))
+ cursor = NULL;
+ else
+ cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
GDK_HAND2);
gdk_window_set_cursor (grip->title_window, cursor);
- if (cursor)
+ if (cursor)
gdk_cursor_unref (cursor);
}
}
@@ -451,12 +457,13 @@ gdl_dock_item_grip_unrealize (GtkWidget *widget)
GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget);
if (grip->title_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
@@ -464,7 +471,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);
@@ -478,7 +485,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
@@ -486,79 +493,39 @@ gdl_dock_item_grip_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkRequisition child_requisition;
- GtkContainer *container;
GdlDockItemGrip *grip;
- gint layout_height;
+ 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;
- ensure_title_and_icon_pixbuf (grip);
- pango_layout_get_pixel_size (grip->_priv->title_layout, NULL, &layout_height);
+ if(grip->_priv->handle_shown)
+ requisition->width += DRAG_HANDLE_SIZE;
gtk_widget_size_request (grip->_priv->close_button, &child_requisition);
-
- requisition->width += child_requisition.width;
layout_height = MAX (layout_height, child_requisition.height);
+ if (gtk_widget_get_visible (grip->_priv->close_button)) {
+ requisition->width += child_requisition.width;
+ }
gtk_widget_size_request (grip->_priv->iconify_button, &child_requisition);
-
+ layout_height = MAX (layout_height, child_requisition.height);
+ if (gtk_widget_get_visible (grip->_priv->iconify_button)) {
+ requisition->width += child_requisition.width;
+ }
+
+ gtk_widget_size_request (grip->_priv->label, &child_requisition);
requisition->width += child_requisition.width;
layout_height = MAX (layout_height, child_requisition.height);
requisition->height += layout_height;
-
- if (grip->_priv->icon_pixbuf) {
- requisition->width += gdk_pixbuf_get_width (grip->_priv->icon_pixbuf) + 1;
- }
-}
-
-#define ELLIPSIS "..."
-
-static void
-ellipsize_layout (PangoLayout *layout, gint width)
-{
- PangoLayoutLine *line;
- PangoLayout *ell;
- gint h, w, ell_w, x;
- GString *text;
-
- if (width <= 0) {
- pango_layout_set_text (layout, "", -1);
- return;
- }
-
- pango_layout_get_pixel_size (layout, &w, &h);
- if (w <= width) return;
-
- /* calculate ellipsis width */
- ell = pango_layout_copy (layout);
- pango_layout_set_text (ell, ELLIPSIS, -1);
- pango_layout_get_pixel_size (ell, &ell_w, NULL);
- g_object_unref (ell);
-
- if (width < ell_w) {
- /* not even ellipsis fits, so hide the text */
- pango_layout_set_text (layout, "", -1);
- return;
- }
-
- /* shrink total available width by the width of the ellipsis */
- width -= ell_w;
- line = pango_layout_get_line (layout, 0);
- text = g_string_new (pango_layout_get_text (layout));
- if (pango_layout_line_x_to_index (line, width * PANGO_SCALE, &x, NULL)) {
- g_string_set_size (text, x);
- g_string_append (text, ELLIPSIS);
- pango_layout_set_text (layout, text->str, -1);
- }
- g_string_free (text, TRUE);
}
static void
@@ -566,69 +533,110 @@ gdl_dock_item_grip_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GdlDockItemGrip *grip;
- GtkContainer *container;
- GtkRequisition button_requisition = { 0, };
+ 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);
+ gtk_widget_size_request (grip->_priv->iconify_button,
+ &iconify_requisition);
+
+ /* Calculate the Minimum Width where buttons will fit */
+ int min_width = close_requisition.width + iconify_requisition.width
+ + 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 = allocation->x + container->border_width + ALIGN_BORDER;
+ child_allocation.x = border_width/* + ALIGN_BORDER*/;
else
- child_allocation.x = allocation->x + allocation->width - container->border_width;
- child_allocation.y = allocation->y + container->border_width;
+ child_allocation.x = allocation->width - border_width;
+ child_allocation.y = border_width;
- gtk_widget_size_request (grip->_priv->close_button, &button_requisition);
+ /* Layout Close Button */
+ if (gtk_widget_get_visible (grip->_priv->close_button)) {
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL)
- child_allocation.x -= button_requisition.width;
-
- child_allocation.width = button_requisition.width;
- child_allocation.height = button_requisition.height;
-
- gtk_widget_size_allocate (grip->_priv->close_button, &child_allocation);
-
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- child_allocation.x += button_requisition.width;
-
+ if(space_for_buttons) {
+ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL)
+ child_allocation.x -= close_requisition.width;
+
+ child_allocation.width = close_requisition.width;
+ child_allocation.height = close_requisition.height;
+ } else {
+ child_allocation.width = 0;
+ }
+
+ gtk_widget_size_allocate (grip->_priv->close_button, &child_allocation);
- gtk_widget_size_request (grip->_priv->iconify_button, &button_requisition);
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ child_allocation.x += close_requisition.width;
+ }
- if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL)
- child_allocation.x -= button_requisition.width;
+ /* Layout Iconify Button */
+ if (gtk_widget_get_visible (grip->_priv->iconify_button)) {
- child_allocation.width = button_requisition.width;
- child_allocation.height = button_requisition.height;
+ if(space_for_buttons) {
+ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL)
+ child_allocation.x -= iconify_requisition.width;
- gtk_widget_size_allocate (grip->_priv->iconify_button, &child_allocation);
+ child_allocation.width = iconify_requisition.width;
+ child_allocation.height = iconify_requisition.height;
+ } else {
+ child_allocation.width = 0;
+ }
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- child_allocation.x += button_requisition.width;
+ gtk_widget_size_allocate (grip->_priv->iconify_button, &child_allocation);
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
+ child_allocation.x += iconify_requisition.width;
+ }
- if (grip->title_window) {
- GdkRectangle area;
+ /* Layout the Grip Handle*/
+ if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) {
+ child_allocation.width = child_allocation.x;
+ child_allocation.x = border_width/* + ALIGN_BORDER*/;
- /* set layout text */
- ensure_title_and_icon_pixbuf (grip);
- pango_layout_set_text (grip->_priv->title_layout, grip->_priv->title, -1);
-
- gdl_dock_item_grip_get_title_area (grip, &area);
-
- gdk_window_move_resize (grip->title_window,
- area.x, area.y, area.width, area.height);
-
- if (grip->_priv->icon_pixbuf)
- area.width -= gdk_pixbuf_get_width (grip->_priv->icon_pixbuf) + 1;
+ if(grip->_priv->handle_shown) {
+ child_allocation.x += DRAG_HANDLE_SIZE;
+ child_allocation.width -= DRAG_HANDLE_SIZE;
+ }
+
+ } else {
+ child_allocation.width = allocation->width -
+ (child_allocation.x - allocation->x)/* - ALIGN_BORDER*/;
- /* ellipsize title if it doesn't fit the title area */
- ellipsize_layout (grip->_priv->title_layout, area.width);
+ if(grip->_priv->handle_shown)
+ child_allocation.width -= DRAG_HANDLE_SIZE;
+ }
+
+ if(child_allocation.width < 0)
+ child_allocation.width = 0;
+
+ 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);
+ }
+
+ if (grip->title_window) {
+ gdk_window_move_resize (grip->title_window,
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
}
}
@@ -636,6 +644,8 @@ static void
gdl_dock_item_grip_add (GtkContainer *container,
GtkWidget *widget)
{
+ (void)container;
+ (void)widget;
g_warning ("gtk_container_add not implemented for GdlDockItemGrip");
}
@@ -643,7 +653,8 @@ static void
gdl_dock_item_grip_remove (GtkContainer *container,
GtkWidget *widget)
{
- g_warning ("gtk_container_remove not implemented for GdlDockItemGrip");
+ (void)widget;
+ gdl_dock_item_grip_set_label (GDL_DOCK_ITEM_GRIP (container), NULL);
}
static void
@@ -655,18 +666,24 @@ gdl_dock_item_grip_forall (GtkContainer *container,
GdlDockItemGrip *grip;
g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (container));
-
grip = GDL_DOCK_ITEM_GRIP (container);
+
+ if (grip->_priv) {
+ if(grip->_priv->label) {
+ (* callback) (grip->_priv->label, callback_data);
+ }
- if (include_internals) {
- (* callback) (grip->_priv->close_button, callback_data);
- (* callback) (grip->_priv->iconify_button, callback_data);
+ if (include_internals) {
+ (* callback) (grip->_priv->close_button, callback_data);
+ (* callback) (grip->_priv->iconify_button, callback_data);
+ }
}
}
-static GtkType
+static GType
gdl_dock_item_grip_child_type (GtkContainer *container)
{
+ (void)container;
return G_TYPE_NONE;
}
@@ -678,7 +695,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);
@@ -707,11 +723,23 @@ gdl_dock_item_grip_class_init (GdlDockItemGripClass *klass)
_("Dockitem which 'owns' this grip"),
GDL_TYPE_DOCK_ITEM,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+}
- /* initialize stock images */
- gdl_stock_init ();
+static void
+gdl_dock_item_grip_showhide_handle (GdlDockItemGrip *grip)
+{
+ gtk_widget_queue_resize (GTK_WIDGET (grip));
}
+/* ----- Public interface ----- */
+
+/**
+ * gdl_dock_item_grip_new:
+ * @item: The dock item that will "own" this grip widget.
+ *
+ * Creates a new GDL dock item grip object.
+ * Returns: The newly created dock item grip widget.
+ **/
GtkWidget *
gdl_dock_item_grip_new (GdlDockItem *item)
{
@@ -720,3 +748,61 @@ gdl_dock_item_grip_new (GdlDockItem *item)
return GTK_WIDGET (grip);
}
+
+/**
+ * gdl_dock_item_grip_set_label:
+ * @grip: The grip that will get it's label widget set.
+ * @label: The widget that will become the label.
+ *
+ * Replaces the current label widget with another widget.
+ **/
+void
+gdl_dock_item_grip_set_label (GdlDockItemGrip *grip,
+ GtkWidget *label)
+{
+ g_return_if_fail (grip != NULL);
+
+ if (grip->_priv->label) {
+ gtk_widget_unparent(grip->_priv->label);
+ g_object_unref (grip->_priv->label);
+ grip->_priv->label = NULL;
+ }
+
+ if (label) {
+ g_object_ref (label);
+ gtk_widget_set_parent (label, GTK_WIDGET (grip));
+ gtk_widget_show (label);
+ grip->_priv->label = label;
+ }
+}
+/**
+ * gdl_dock_item_grip_hide_handle:
+ * @grip: The dock item grip to hide the handle of.
+ *
+ * This function hides the dock item's grip widget handle hatching.
+ **/
+void
+gdl_dock_item_grip_hide_handle (GdlDockItemGrip *grip)
+{
+ g_return_if_fail (grip != NULL);
+ if (grip->_priv->handle_shown) {
+ grip->_priv->handle_shown = FALSE;
+ gdl_dock_item_grip_showhide_handle (grip);
+ };
+}
+
+/**
+ * gdl_dock_item_grip_show_handle:
+ * @grip: The dock item grip to show the handle of.
+ *
+ * This function shows the dock item's grip widget handle hatching.
+ **/
+void
+gdl_dock_item_grip_show_handle (GdlDockItemGrip *grip)
+{
+ g_return_if_fail (grip != NULL);
+ if (!grip->_priv->handle_shown) {
+ grip->_priv->handle_shown = TRUE;
+ gdl_dock_item_grip_showhide_handle (grip);
+ };
+}
diff --git a/src/libgdl/gdl-dock-item-grip.h b/src/libgdl/gdl-dock-item-grip.h
index 377ea1470..a44ef91fb 100644
--- a/src/libgdl/gdl-dock-item-grip.h
+++ b/src/libgdl/gdl-dock-item-grip.h
@@ -1,34 +1,51 @@
/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
-/**
+/*
* gdl-dock-item-grip.h
- *
- * Based on bonobo-dock-item-grip. Original copyright notice follows.
*
- * Author:
- * Michael Meeks
+ * Author: Michael Meeks Copyright (C) 2002 Sun Microsystems, Inc.
*
- * Copyright (C) 2002 Sun Microsystems, Inc.
+ * Based on BonoboDockItemGrip. Original copyright notice follows.
+ *
+ * Copyright (C) 1998 Ettore Perazzoli
+ * Copyright (C) 1998 Elliot Lee
+ * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
+ * All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
*/
#ifndef _GDL_DOCK_ITEM_GRIP_H_
#define _GDL_DOCK_ITEM_GRIP_H_
-#include <gtk/gtkwidget.h>
+#include <gtk/gtk.h>
#include "libgdl/gdl-dock-item.h"
G_BEGIN_DECLS
#define GDL_TYPE_DOCK_ITEM_GRIP (gdl_dock_item_grip_get_type())
#define GDL_DOCK_ITEM_GRIP(obj) \
- (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGrip))
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGrip))
#define GDL_DOCK_ITEM_GRIP_CLASS(klass) \
- (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGripClass))
+ (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGripClass))
#define GDL_IS_DOCK_ITEM_GRIP(obj) \
- (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_ITEM_GRIP))
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM_GRIP))
#define GDL_IS_DOCK_ITEM_GRIP_CLASS(klass) \
- (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM_GRIP))
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM_GRIP))
#define GDL_DOCK_ITEM_GRIP_GET_CLASS(obj) \
- (GTK_CHECK_GET_CLASS ((obj), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGripClass))
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGripClass))
typedef struct _GdlDockItemGrip GdlDockItemGrip;
typedef struct _GdlDockItemGripClass GdlDockItemGripClass;
@@ -50,6 +67,10 @@ struct _GdlDockItemGripClass {
GType gdl_dock_item_grip_get_type (void);
GtkWidget *gdl_dock_item_grip_new (GdlDockItem *item);
+void gdl_dock_item_grip_set_label (GdlDockItemGrip *grip,
+ GtkWidget *label);
+void gdl_dock_item_grip_hide_handle (GdlDockItemGrip *grip);
+void gdl_dock_item_grip_show_handle (GdlDockItemGrip *grip);
G_END_DECLS
diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c
index 01a777bad..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,
@@ -79,11 +77,10 @@ static void gdl_dock_item_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
-static GtkType gdl_dock_item_child_type (GtkContainer *container);
+static GType gdl_dock_item_child_type (GtkContainer *container);
static void gdl_dock_item_set_focus_child (GtkContainer *container,
- GtkWidget *widget,
- gpointer callback_data);
+ GtkWidget *widget);
static void gdl_dock_item_size_request (GtkWidget *widget,
GtkRequisition *requisition);
@@ -164,6 +161,7 @@ enum {
DOCK_DRAG_BEGIN,
DOCK_DRAG_MOTION,
DOCK_DRAG_END,
+ SELECTED,
MOVE_FOCUS_CHILD,
LAST_SIGNAL
};
@@ -181,12 +179,15 @@ struct _GdlDockItemPrivate {
guint grip_size;
GtkWidget *tab_label;
+ gboolean intern_tab_label;
+ guint notify_label;
+ guint notify_stock_id;
gint preferred_width;
gint preferred_height;
GdlDockPlaceholder *ph;
-
+
gint start_x, start_y;
};
@@ -197,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,
@@ -282,6 +283,16 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
/* properties */
+ /**
+ * GdlDockItem:orientation:
+ *
+ * The orientation of the docking item. If the orientation is set to
+ * #GTK_ORIENTATION_VERTICAL, the grip widget will be shown along
+ * the top of the edge of item (if it is not hidden). If the
+ * orientation is set to #GTK_ORIENTATION_HORIZONTAL, the grip
+ * widget will be shown down the left edge of the item (even if the
+ * widget text direction is set to RTL).
+ */
g_object_class_install_property (
g_object_class, PROP_ORIENTATION,
g_param_spec_enum ("orientation", _("Orientation"),
@@ -302,7 +313,7 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
g_object_class, PROP_RESIZE,
g_param_spec_boolean ("resize", _("Resizable"),
_("If set, the dock item can be resized when "
- "docked in a panel"),
+ "docked in a GtkPanel widget"),
TRUE,
G_PARAM_READWRITE));
@@ -340,6 +351,12 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
/* signals */
+ /**
+ * GdlDockItem::dock-drag-begin:
+ * @item: The dock item which is being dragged.
+ *
+ * Signals that the dock item has begun to be dragged.
+ **/
gdl_dock_item_signals [DOCK_DRAG_BEGIN] =
g_signal_new ("dock-drag-begin",
G_TYPE_FROM_CLASS (klass),
@@ -350,7 +367,15 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
gdl_marshal_VOID__VOID,
G_TYPE_NONE,
0);
-
+
+ /**
+ * GdlDockItem::dock-drag-motion:
+ * @item: The dock item which is being dragged.
+ * @x: The x-position that the dock item has been dragged to.
+ * @y: The y-position that the dock item has been dragged to.
+ *
+ * Signals that a dock item dragging motion event has occured.
+ **/
gdl_dock_item_signals [DOCK_DRAG_MOTION] =
g_signal_new ("dock-drag-motion",
G_TYPE_FROM_CLASS (klass),
@@ -364,6 +389,14 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
G_TYPE_INT,
G_TYPE_INT);
+ /**
+ * GdlDockItem::dock-drag-end:
+ * @item: The dock item which is no longer being dragged.
+ * @cancel: This value is set to TRUE if the drag was cancelled by
+ * the user. #cancel is set to FALSE if the drag was accepted.
+ *
+ * Signals that the dock item dragging has ended.
+ **/
gdl_dock_item_signals [DOCK_DRAG_END] =
g_signal_new ("dock_drag_end",
G_TYPE_FROM_CLASS (klass),
@@ -376,6 +409,22 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
1,
G_TYPE_BOOLEAN);
+ /**
+ * GdlDockItem::selected:
+ *
+ * Signals that this dock has been selected from a switcher.
+ */
+ gdl_dock_item_signals [SELECTED] =
+ g_signal_new ("selected",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
gdl_dock_item_signals [MOVE_FOCUS_CHILD] =
g_signal_new ("move_focus_child",
G_TYPE_FROM_CLASS (klass),
@@ -424,10 +473,10 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
}
static void
-gdl_dock_item_instance_init (GdlDockItem *item)
+gdl_dock_item_init (GdlDockItem *item)
{
- GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (item), GTK_NO_WINDOW);
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (item), GTK_CAN_FOCUS);
+ gtk_widget_set_has_window (GTK_WIDGET (item), TRUE);
+ gtk_widget_set_can_focus (GTK_WIDGET (item), TRUE);
item->child = NULL;
@@ -443,10 +492,33 @@ gdl_dock_item_instance_init (GdlDockItem *item)
item->_priv->preferred_width = item->_priv->preferred_height = -1;
item->_priv->tab_label = NULL;
+ item->_priv->intern_tab_label = FALSE;
item->_priv->ph = NULL;
}
+static void
+on_long_name_changed (GObject* item,
+ GParamSpec* spec,
+ gpointer user_data)
+{
+ gchar* long_name;
+ g_object_get (item, "long-name", &long_name, NULL);
+ gtk_label_set_label (GTK_LABEL (user_data), long_name);
+ g_free(long_name);
+}
+
+static void
+on_stock_id_changed (GObject* item,
+ GParamSpec* spec,
+ gpointer user_data)
+{
+ gchar* stock_id;
+ g_object_get (item, "stock_id", &stock_id, NULL);
+ gtk_image_set_from_stock (GTK_IMAGE (user_data), stock_id, GTK_ICON_SIZE_MENU);
+ g_free(stock_id);
+}
+
static GObject *
gdl_dock_item_constructor (GType type,
guint n_construct_properties,
@@ -454,14 +526,16 @@ 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;
+ GtkWidget *label;
+ GtkWidget *icon;
+ gchar* long_name;
+ gchar* stock_id;
if (GDL_DOCK_ITEM_HAS_GRIP (item)) {
item->_priv->grip_shown = TRUE;
@@ -472,6 +546,32 @@ gdl_dock_item_constructor (GType type,
else {
item->_priv->grip_shown = FALSE;
}
+
+ g_object_get (g_object, "long-name", &long_name, "stock-id", &stock_id, NULL);
+
+ hbox = gtk_hbox_new (FALSE, 5);
+ label = gtk_label_new (long_name);
+ icon = gtk_image_new ();
+ if (stock_id)
+ gtk_image_set_from_stock (GTK_IMAGE (icon), stock_id,
+ GTK_ICON_SIZE_MENU);
+ gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ item->_priv->notify_label =
+ g_signal_connect (item, "notify::long-name", G_CALLBACK (on_long_name_changed),
+ label);
+ item->_priv->notify_stock_id =
+ g_signal_connect (item, "notify::stock-id", G_CALLBACK (on_stock_id_changed),
+ icon);
+
+ gtk_widget_show_all (hbox);
+
+ gdl_dock_item_set_tablabel (item, hbox);
+ item->_priv->intern_tab_label = TRUE;
+
+ g_free (long_name);
+ g_free (stock_id);
}
return g_object;
@@ -600,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
@@ -644,7 +744,7 @@ gdl_dock_item_remove (GtkContainer *container,
item = GDL_DOCK_ITEM (container);
if (item->_priv && widget == item->_priv->grip) {
- gboolean grip_was_visible = GTK_WIDGET_VISIBLE (widget);
+ gboolean grip_was_visible = gtk_widget_get_visible (widget);
gtk_widget_unparent (widget);
item->_priv->grip = NULL;
if (grip_was_visible)
@@ -658,7 +758,7 @@ gdl_dock_item_remove (GtkContainer *container,
g_return_if_fail (item->child == widget);
- was_visible = GTK_WIDGET_VISIBLE (widget);
+ was_visible = gtk_widget_get_visible (widget);
gtk_widget_unparent (widget);
item->child = NULL;
@@ -684,7 +784,7 @@ gdl_dock_item_forall (GtkContainer *container,
(* callback) (item->child, callback_data);
}
-static GtkType
+static GType
gdl_dock_item_child_type (GtkContainer *container)
{
g_return_val_if_fail (GDL_IS_DOCK_ITEM (container), G_TYPE_NONE);
@@ -697,13 +797,13 @@ gdl_dock_item_child_type (GtkContainer *container)
static void
gdl_dock_item_set_focus_child (GtkContainer *container,
- GtkWidget *child,
- gpointer callback_data)
+ GtkWidget *child)
{
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));
}
@@ -712,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);
@@ -758,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);
- widget->requisition = *requisition;
+ requisition->width += (border_width + style->xthickness) * 2;
+ requisition->height += (border_width + style->ythickness) * 2;
+
+ //gtk_widget_size_request (widget, requisition);
}
static void
@@ -775,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_REALIZED (widget))
- gdk_window_move_resize (widget->window,
- widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
-
- if (item->child && GTK_WIDGET_VISIBLE (item->child)) {
+ if (gtk_widget_get_realized (widget))
+ 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;
@@ -836,20 +943,20 @@ gdl_dock_item_map (GtkWidget *widget)
g_return_if_fail (widget != NULL);
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
- GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
+ gtk_widget_set_mapped (widget, TRUE);
item = GDL_DOCK_ITEM (widget);
- gdk_window_show (widget->window);
+ gdk_window_show (gtk_widget_get_window (widget));
if (item->child
- && GTK_WIDGET_VISIBLE (item->child)
- && !GTK_WIDGET_MAPPED (item->child))
+ && gtk_widget_get_visible (item->child)
+ && !gtk_widget_get_mapped (item->child))
gtk_widget_map (item->child);
if (item->_priv->grip
- && GTK_WIDGET_VISIBLE (item->_priv->grip)
- && !GTK_WIDGET_MAPPED (item->_priv->grip))
+ && gtk_widget_get_visible (GTK_WIDGET (item->_priv->grip))
+ && !gtk_widget_get_mapped (GTK_WIDGET (item->_priv->grip)))
gtk_widget_map (item->_priv->grip);
}
@@ -861,11 +968,11 @@ gdl_dock_item_unmap (GtkWidget *widget)
g_return_if_fail (widget != NULL);
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
- GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+ gtk_widget_set_mapped (widget, FALSE);
item = GDL_DOCK_ITEM (widget);
- gdk_window_hide (widget->window);
+ gdk_window_hide (gtk_widget_get_window (widget));
if (item->_priv->grip)
gtk_widget_unmap (item->_priv->grip);
@@ -874,22 +981,25 @@ gdl_dock_item_unmap (GtkWidget *widget)
static void
gdl_dock_item_realize (GtkWidget *widget)
{
+ GdlDockItem *item;
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
- GdlDockItem *item;
g_return_if_fail (widget != NULL);
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
item = GDL_DOCK_ITEM (widget);
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ gtk_widget_set_realized (widget, TRUE);
/* widget window */
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
@@ -900,34 +1010,42 @@ 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,
- GTK_WIDGET_STATE (item));
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
+ 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 (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);
g_return_if_fail (GDL_IS_DOCK_ITEM (widget));
- if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget)) {
- gtk_style_set_background (widget->style, widget->window,
- widget->state);
- if (GTK_WIDGET_DRAWABLE (widget))
- gdk_window_clear (widget->window);
+ if (gtk_widget_get_realized (widget) &&
+ gtk_widget_get_has_window (widget))
+ {
+ 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 (window);
}
}
@@ -939,9 +1057,9 @@ gdl_dock_item_paint (GtkWidget *widget,
item = GDL_DOCK_ITEM (widget);
- gtk_paint_box (widget->style,
- widget->window,
- GTK_WIDGET_STATE (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,
"dockitem",
@@ -956,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_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;
@@ -983,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);
@@ -1001,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;
@@ -1123,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
@@ -1135,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;
@@ -1159,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) {
@@ -1186,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;
@@ -1234,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;
@@ -1260,8 +1380,10 @@ gdl_dock_item_dock (GdlDockObject *object,
GdlDockPlacement position,
GValue *other_data)
{
- GdlDockObject *new_parent, *parent;
- gboolean add_ourselves_first;
+ GdlDockObject *new_parent = NULL;
+ GdlDockObject *parent, *requestor_parent;
+ GtkAllocation allocation;
+ gboolean add_ourselves_first = FALSE;
guint available_space=0;
gint pref_size=-1;
@@ -1275,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),
@@ -1375,11 +1498,16 @@ gdl_dock_item_dock (GdlDockObject *object,
pref_size = req.width;
break;
case GDL_DOCK_CENTER:
- new_parent = g_object_new (gdl_dock_object_type_from_nick ("notebook"),
- "preferred-width", object_req.width,
- "preferred-height", object_req.height,
- NULL);
- add_ourselves_first = TRUE;
+ /* If the parent is already a DockNotebook, we don't need
+ to create a new one. */
+ if (!GDL_IS_DOCK_NOTEBOOK (parent))
+ {
+ new_parent = g_object_new (gdl_dock_object_type_from_nick ("notebook"),
+ "preferred-width", object_req.width,
+ "preferred-height", object_req.height,
+ NULL);
+ add_ourselves_first = TRUE;
+ }
break;
default:
{
@@ -1398,52 +1526,73 @@ gdl_dock_item_dock (GdlDockObject *object,
if (parent)
gdl_dock_object_freeze (parent);
- /* ref ourselves since we could be destroyed when detached */
- g_object_ref (object);
- GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_REFLOW);
- gdl_dock_object_detach (object, FALSE);
-
- /* freeze the new parent, so reduce won't get called before it's
- actually added to our parent */
- gdl_dock_object_freeze (new_parent);
- /* bind the new parent to our master, so the following adds work */
- gdl_dock_object_bind (new_parent, G_OBJECT (GDL_DOCK_OBJECT_GET_MASTER (object)));
+ if (new_parent)
+ {
+ /* ref ourselves since we could be destroyed when detached */
+ g_object_ref (object);
+ GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_REFLOW);
+ gdl_dock_object_detach (object, FALSE);
+
+ /* freeze the new parent, so reduce won't get called before it's
+ actually added to our parent */
+ gdl_dock_object_freeze (new_parent);
- /* add the objects */
- if (add_ourselves_first) {
- gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
- gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
- splitpos = available_space - pref_size;
- } else {
- gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
- gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
- splitpos = pref_size;
- }
+ /* bind the new parent to our master, so the following adds work */
+ gdl_dock_object_bind (new_parent, G_OBJECT (GDL_DOCK_OBJECT_GET_MASTER (object)));
+
+ /* add the objects */
+ if (add_ourselves_first) {
+ gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
+ gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
+ splitpos = available_space - pref_size;
+ } else {
+ gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor));
+ gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object));
+ splitpos = pref_size;
+ }
- /* add the new parent to the parent */
- if (parent)
- gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (new_parent));
+ /* add the new parent to the parent */
+ if (parent)
+ gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (new_parent));
- /* show automatic object */
- if (GTK_WIDGET_VISIBLE (object))
- gtk_widget_show (GTK_WIDGET (new_parent));
-
- /* use extra docking parameter */
- if (position != GDL_DOCK_CENTER && other_data &&
- G_VALUE_HOLDS (other_data, G_TYPE_UINT)) {
+ /* show automatic object */
+ if (gtk_widget_get_visible (GTK_WIDGET (object)))
+ {
+ gtk_widget_show (GTK_WIDGET (new_parent));
+ GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW);
+ }
+ gdl_dock_object_thaw (new_parent);
+
+ /* use extra docking parameter */
+ if (position != GDL_DOCK_CENTER && other_data &&
+ G_VALUE_HOLDS (other_data, G_TYPE_UINT)) {
- g_object_set (G_OBJECT (new_parent),
- "position", g_value_get_uint (other_data),
- NULL);
- } else if (splitpos > 0 && splitpos < available_space) {
- g_object_set (G_OBJECT (new_parent), "position", splitpos, NULL);
+ g_object_set (G_OBJECT (new_parent),
+ "position", g_value_get_uint (other_data),
+ NULL);
+ } else if (splitpos > 0 && splitpos < available_space) {
+ g_object_set (G_OBJECT (new_parent), "position", splitpos, NULL);
+ }
+
+ g_object_unref (object);
+ }
+ else
+ {
+ /* If the parent is already a DockNotebook, we don't need
+ to create a new one. */
+ gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (requestor));
}
- GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW);
- g_object_unref (object);
-
- gdl_dock_object_thaw (new_parent);
+ requestor_parent = gdl_dock_object_get_parent_object (requestor);
+ if (GDL_IS_DOCK_NOTEBOOK (requestor_parent))
+ {
+ /* Activate the page we just added */
+ GdlDockItem* notebook = GDL_DOCK_ITEM (gdl_dock_object_get_parent_object (requestor));
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook->child),
+ gtk_notebook_page_num (GTK_NOTEBOOK (notebook->child), GTK_WIDGET (requestor)));
+ }
+
if (parent)
gdl_dock_object_thaw (parent);
@@ -1454,9 +1603,10 @@ static void
gdl_dock_item_detach_menu (GtkWidget *widget,
GtkMenu *menu)
{
- GdlDockItem *item;
-
- item = GDL_DOCK_ITEM (widget);
+ GdlDockItem *item = GDL_DOCK_ITEM(widget);
+
+ (void)menu;
+
item->_priv->menu = NULL;
}
@@ -1506,7 +1656,7 @@ gdl_dock_item_drag_start (GdlDockItem *item)
{
GdkCursor *fleur;
- if (!GTK_WIDGET_REALIZED (item))
+ if (!gtk_widget_get_realized (GTK_WIDGET (item)))
gtk_widget_realize (GTK_WIDGET (item));
GDL_DOCK_ITEM_SET_FLAGS (item, GDL_DOCK_IN_DRAG);
@@ -1540,11 +1690,15 @@ gdl_dock_item_tab_button (GtkWidget *widget,
gpointer data)
{
GdlDockItem *item;
+ GtkAllocation allocation;
+
+ item = GDL_DOCK_ITEM(data);
- item = GDL_DOCK_ITEM (data);
+ (void)widget;
- if (!GDL_DOCK_ITEM_NOT_LOCKED (item))
+ if (!GDL_DOCK_ITEM_NOT_LOCKED (item)) {
return;
+ }
switch (event->button) {
case 1:
@@ -1552,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;*/
@@ -1576,11 +1731,10 @@ static void
gdl_dock_item_hide_cb (GtkWidget *widget,
GdlDockItem *item)
{
- GdlDockMaster *master;
-
+ (void)widget;
+
g_return_if_fail (item != NULL);
- master = GDL_DOCK_OBJECT_GET_MASTER (item);
gdl_dock_item_hide_item (item);
}
@@ -1590,6 +1744,8 @@ gdl_dock_item_lock_cb (GtkWidget *widget,
{
g_return_if_fail (item != NULL);
+ (void)widget;
+
gdl_dock_item_lock (item);
}
@@ -1599,6 +1755,8 @@ gdl_dock_item_unlock_cb (GtkWidget *widget,
{
g_return_if_fail (item != NULL);
+ (void)widget;
+
gdl_dock_item_unlock (item);
}
@@ -1632,7 +1790,7 @@ gdl_dock_item_real_set_orientation (GdlDockItem *item,
{
item->orientation = orientation;
- if (GTK_WIDGET_DRAWABLE (item))
+ if (gtk_widget_is_drawable (GTK_WIDGET (item)))
gtk_widget_queue_draw (GTK_WIDGET (item));
gtk_widget_queue_resize (GTK_WIDGET (item));
}
@@ -1640,6 +1798,17 @@ gdl_dock_item_real_set_orientation (GdlDockItem *item,
/* ----- Public interface ----- */
+/**
+ * gdl_dock_item_new:
+ * @name: Unique name for identifying the dock object.
+ * @long_name: Human readable name for the dock object.
+ * @behavior: General behavior for the dock item (i.e. whether it can
+ * float, if it's locked, etc.), as specified by
+ * #GdlDockItemBehavior flags.
+ *
+ * Creates a new dock item widget.
+ * Returns: The newly created dock item grip widget.
+ **/
GtkWidget *
gdl_dock_item_new (const gchar *name,
const gchar *long_name,
@@ -1653,10 +1822,22 @@ gdl_dock_item_new (const gchar *name,
"behavior", behavior,
NULL));
GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC);
- gdl_dock_item_set_tablabel (item, gtk_label_new (long_name));
+
return GTK_WIDGET (item);
}
+/**
+ * gdl_dock_item_new_with_stock:
+ * @name: Unique name for identifying the dock object.
+ * @long_name: Human readable name for the dock object.
+ * @stock_id: Stock icon for the dock object.
+ * @behavior: General behavior for the dock item (i.e. whether it can
+ * float, if it's locked, etc.), as specified by
+ * #GdlDockItemBehavior flags.
+ *
+ * Creates a new dock item grip widget with a given stock id.
+ * Returns: The newly created dock item grip widget.
+ **/
GtkWidget *
gdl_dock_item_new_with_stock (const gchar *name,
const gchar *long_name,
@@ -1672,8 +1853,7 @@ gdl_dock_item_new_with_stock (const gchar *name,
"behavior", behavior,
NULL));
GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC);
- gdl_dock_item_set_tablabel (item, gtk_label_new (long_name));
-
+
return GTK_WIDGET (item);
}
@@ -1699,12 +1879,23 @@ gdl_dock_item_new_with_pixbuf_icon (const gchar *name,
}
/* convenient function (and to preserve source compat) */
+/**
+ * gdl_dock_item_dock_to:
+ * @item: The dock item that will be relocated to the dock position.
+ * @target: (allow-none): The dock item that will be used as the point of reference.
+ * @position: The position to dock #item, relative to #target.
+ * @docking_param: This value is unused, and will be ignored.
+ *
+ * Relocates a dock item to a new location relative to another dock item.
+ **/
void
gdl_dock_item_dock_to (GdlDockItem *item,
GdlDockItem *target,
GdlDockPlacement position,
gint docking_param)
{
+ (void)docking_param;
+
g_return_if_fail (item != NULL);
g_return_if_fail (item != target);
g_return_if_fail (target != NULL || position == GDL_DOCK_FLOATING);
@@ -1734,6 +1925,18 @@ gdl_dock_item_dock_to (GdlDockItem *item,
position, NULL);
}
+/**
+ * gdl_dock_item_set_orientation:
+ * @item: The dock item which will get it's orientation set.
+ * @orientation: The orientation to set the item to. If the orientation
+ * is set to #GTK_ORIENTATION_VERTICAL, the grip widget will be shown
+ * along the top of the edge of item (if it is not hidden). If the
+ * orientation is set to #GTK_ORIENTATION_HORIZONTAL, the grip widget
+ * will be shown down the left edge of the item (even if the widget
+ * text direction is set to RTL).
+ *
+ * This function sets the layout of the dock item.
+ **/
void
gdl_dock_item_set_orientation (GdlDockItem *item,
GtkOrientation orientation)
@@ -1752,12 +1955,22 @@ 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");
}
}
+/**
+ * gdl_dock_item_get_tablabel:
+ * @item: The dock item from which to get the tab label widget.
+ *
+ * Gets the current tab label widget. Note that this label widget is
+ * only visible when the "switcher-style" property of the #GdlDockMaster
+ * is set to #GDL_SWITCHER_STYLE_TABS
+ *
+ * Returns: Returns the tab label widget.
+ **/
GtkWidget *
gdl_dock_item_get_tablabel (GdlDockItem *item)
{
@@ -1767,12 +1980,28 @@ gdl_dock_item_get_tablabel (GdlDockItem *item)
return item->_priv->tab_label;
}
+/**
+ * gdl_dock_item_set_tablabel:
+ * @item: The dock item which will get it's tab label widget set.
+ * @tablabel: The widget that will become the tab label.
+ *
+ * Replaces the current tab label widget with another widget. Note that
+ * this label widget is only visible when the "switcher-style" property
+ * of the #GdlDockMaster is set to #GDL_SWITCHER_STYLE_TABS
+ **/
void
gdl_dock_item_set_tablabel (GdlDockItem *item,
GtkWidget *tablabel)
{
g_return_if_fail (item != NULL);
+ if (item->_priv->intern_tab_label)
+ {
+ item->_priv->intern_tab_label = FALSE;
+ g_signal_handler_disconnect (item, item->_priv->notify_label);
+ g_signal_handler_disconnect (item, item->_priv->notify_stock_id);
+ }
+
if (item->_priv->tab_label) {
/* disconnect and unref the previous tablabel */
if (GDL_IS_DOCK_TABLABEL (item->_priv->tab_label)) {
@@ -1782,13 +2011,12 @@ gdl_dock_item_set_tablabel (GdlDockItem *item,
NULL, item);
g_object_set (item->_priv->tab_label, "item", NULL, NULL);
}
- gtk_widget_unref (item->_priv->tab_label);
+ g_object_unref (item->_priv->tab_label);
item->_priv->tab_label = NULL;
}
if (tablabel) {
- gtk_widget_ref (tablabel);
- gtk_object_sink (GTK_OBJECT (tablabel));
+ g_object_ref_sink (G_OBJECT (tablabel));
item->_priv->tab_label = tablabel;
if (GDL_IS_DOCK_TABLABEL (tablabel)) {
g_object_set (tablabel, "item", item, NULL);
@@ -1799,6 +2027,29 @@ gdl_dock_item_set_tablabel (GdlDockItem *item,
}
}
+/**
+ * gdl_dock_item_get_grip:
+ * @item: The dock item from which to to get the grip of.
+ *
+ * This function returns the dock item's grip label widget.
+ *
+ * Returns: Returns the current label widget.
+ **/
+GtkWidget *
+gdl_dock_item_get_grip(GdlDockItem *item)
+{
+ g_return_val_if_fail (item != NULL, NULL);
+ g_return_val_if_fail (GDL_IS_DOCK_ITEM (item), NULL);
+
+ return item->_priv->grip;
+}
+
+/**
+ * gdl_dock_item_hide_grip:
+ * @item: The dock item to hide the grip of.
+ *
+ * This function hides the dock item's grip widget.
+ **/
void
gdl_dock_item_hide_grip (GdlDockItem *item)
{
@@ -1810,6 +2061,12 @@ gdl_dock_item_hide_grip (GdlDockItem *item)
g_warning ("Grips always show unless GDL_DOCK_ITEM_BEH_NO_GRIP is set\n" );
}
+/**
+ * gdl_dock_item_show_grip:
+ * @item: The dock item to show the grip of.
+ *
+ * This function shows the dock item's grip widget.
+ **/
void
gdl_dock_item_show_grip (GdlDockItem *item)
{
@@ -1820,7 +2077,28 @@ gdl_dock_item_show_grip (GdlDockItem *item)
};
}
+/**
+ * gdl_dock_item_notify_selected:
+ * @item: the dock item to emit a selected signal on.
+ *
+ * This function emits the selected signal. It is to be used by #GdlSwitcher
+ * to let clients know that this item has been switched to.
+ **/
+void
+gdl_dock_item_notify_selected (GdlDockItem *item)
+{
+ g_signal_emit (item, gdl_dock_item_signals [SELECTED], 0);
+}
+
/* convenient function (and to preserve source compat) */
+/**
+ * gdl_dock_item_bind:
+ * @item: The item to bind.
+ * @dock: The #GdlDock widget to bind it to. Note that this widget must
+ * be a type of #GdlDock.
+ *
+ * Binds this dock item to a new dock master.
+ **/
void
gdl_dock_item_bind (GdlDockItem *item,
GtkWidget *dock)
@@ -1833,6 +2111,12 @@ gdl_dock_item_bind (GdlDockItem *item,
}
/* convenient function (and to preserve source compat) */
+/**
+ * gdl_dock_item_unbind:
+ * @item: The item to unbind.
+ *
+ * Unbinds this dock item from it's dock master.
+ **/
void
gdl_dock_item_unbind (GdlDockItem *item)
{
@@ -1841,9 +2125,20 @@ gdl_dock_item_unbind (GdlDockItem *item)
gdl_dock_object_unbind (GDL_DOCK_OBJECT (item));
}
+/**
+ * gdl_dock_item_hide_item:
+ * @item: The dock item to hide.
+ *
+ * This function hides the dock item. When dock items are hidden they
+ * are completely removed from the layout.
+ *
+ * The dock item close button causes the panel to be hidden.
+ **/
void
gdl_dock_item_hide_item (GdlDockItem *item)
{
+ GtkAllocation allocation;
+
g_return_if_fail (item != NULL);
if (!GDL_DOCK_OBJECT_ATTACHED (item))
@@ -1870,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,
@@ -1883,8 +2179,7 @@ gdl_dock_item_hide_item (GdlDockItem *item)
"floatx", x,
"floaty", y,
NULL));
- g_object_ref (item->_priv->ph);
- gtk_object_sink (GTK_OBJECT (item->_priv->ph));
+ g_object_ref_sink (item->_priv->ph);
}
gdl_dock_object_freeze (GDL_DOCK_OBJECT (item));
@@ -1903,6 +2198,15 @@ gdl_dock_item_hide_item (GdlDockItem *item)
gdl_dock_object_thaw (GDL_DOCK_OBJECT (item));
}
+/**
+ * gdl_dock_item_iconify_item:
+ * @item: The dock item to iconify.
+ *
+ * This function iconifies the dock item. When dock items are iconified
+ * they are hidden, and appear only as icons in dock bars.
+ *
+ * The dock item iconify button causes the panel to be iconified.
+ **/
void
gdl_dock_item_iconify_item (GdlDockItem *item)
{
@@ -1912,6 +2216,13 @@ gdl_dock_item_iconify_item (GdlDockItem *item)
gdl_dock_item_hide_item (item);
}
+/**
+ * gdl_dock_item_show_item:
+ * @item: The dock item to show.
+ *
+ * This function shows the dock item. When dock items are shown, they
+ * are displayed in their normal layout position.
+ **/
void
gdl_dock_item_show_item (GdlDockItem *item)
{
@@ -1963,18 +2274,41 @@ gdl_dock_item_show_item (GdlDockItem *item)
gtk_widget_show (GTK_WIDGET (item));
}
+/**
+ * gdl_dock_item_lock:
+ * @item: The dock item to lock.
+ *
+ * This function locks the dock item. When locked the dock item cannot
+ * be dragged around and it doesn't show a grip.
+ **/
void
gdl_dock_item_lock (GdlDockItem *item)
{
g_object_set (item, "locked", TRUE, NULL);
}
+/**
+ * gdl_dock_item_unlock:
+ * @item: The dock item to unlock.
+ *
+ * This function unlocks the dock item. When unlocked the dock item can
+ * be dragged around and can show a grip.
+ **/
void
gdl_dock_item_unlock (GdlDockItem *item)
{
g_object_set (item, "locked", FALSE, NULL);
}
+/**
+ * gdl_dock_item_set_default_position:
+ * @item: The dock item
+ * @reference: The GdlDockObject which is the default dock for @item
+ *
+ * This method has only an effect when you add you dock_item with
+ * GDL_DOCK_ITEM_BEH_NEVER_FLOATING. In this case you have to assign
+ * it a default position.
+ **/
void
gdl_dock_item_set_default_position (GdlDockItem *item,
GdlDockObject *reference)
@@ -1988,8 +2322,7 @@ gdl_dock_item_set_default_position (GdlDockItem *item,
if (reference && GDL_DOCK_OBJECT_ATTACHED (reference)) {
if (GDL_IS_DOCK_PLACEHOLDER (reference)) {
- g_object_ref (reference);
- gtk_object_sink (GTK_OBJECT (reference));
+ g_object_ref_sink (reference);
item->_priv->ph = GDL_DOCK_PLACEHOLDER (reference);
} else {
item->_priv->ph = GDL_DOCK_PLACEHOLDER (
@@ -1997,23 +2330,32 @@ gdl_dock_item_set_default_position (GdlDockItem *item,
"sticky", TRUE,
"host", reference,
NULL));
- g_object_ref (item->_priv->ph);
- gtk_object_sink (GTK_OBJECT (item->_priv->ph));
+ g_object_ref_sink (item->_priv->ph);
}
}
}
+/**
+ * gdl_dock_item_preferred_size:
+ * @item: The dock item to get the preferred size of.
+ * @req: A pointer to a #GtkRequisition into which the preferred size
+ * will be written.
+ *
+ * Gets the preferred size of the dock item in pixels.
+ **/
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);
}
@@ -2030,8 +2372,8 @@ gdl_dock_item_or_child_has_focus (GdlDockItem *item)
item_child = GTK_CONTAINER (item_child)->focus_child) ;
item_or_child_has_focus =
- (GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (item)) ||
- (GTK_IS_WIDGET (item_child) && GTK_WIDGET_HAS_FOCUS (item_child)));
+ (gtk_widget_has_focus (GTK_WIDGET (item)) ||
+ (GTK_IS_WIDGET (item_child) && gtk_widget_has_focus (item_child)));
return item_or_child_has_focus;
}
diff --git a/src/libgdl/gdl-dock-item.h b/src/libgdl/gdl-dock-item.h
index 17484ad04..b9378f783 100644
--- a/src/libgdl/gdl-dock-item.h
+++ b/src/libgdl/gdl-dock-item.h
@@ -36,13 +36,32 @@ G_BEGIN_DECLS
/* standard macros */
#define GDL_TYPE_DOCK_ITEM (gdl_dock_item_get_type ())
-#define GDL_DOCK_ITEM(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_ITEM, GdlDockItem))
-#define GDL_DOCK_ITEM_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM, GdlDockItemClass))
-#define GDL_IS_DOCK_ITEM(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_ITEM))
-#define GDL_IS_DOCK_ITEM_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM))
-#define GDL_DOCK_ITEM_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_ITEM, GdlDockItemClass))
+#define GDL_DOCK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM, GdlDockItem))
+#define GDL_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM, GdlDockItemClass))
+#define GDL_IS_DOCK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM))
+#define GDL_IS_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM))
+#define GDL_DOCK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_ITEM, GdlDockItemClass))
+
+/**
+ * GdlDockItemBehavior:
+ * @GDL_DOCK_ITEM_BEH_NORMAL: Normal dock item
+ * @GDL_DOCK_ITEM_BEH_NEVER_FLOATING: item cannot be undocked
+ * @GDL_DOCK_ITEM_BEH_NEVER_VERTICAL: item cannot be docked vertically
+ * @GDL_DOCK_ITEM_BEH_NEVER_HORIZONTAL: item cannot be docked horizontally
+ * @GDL_DOCK_ITEM_BEH_LOCKED: item is locked, it cannot be moved around
+ * @GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP: item cannot be docked at top
+ * @GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM: item cannot be docked at bottom
+ * @GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT: item cannot be docked left
+ * @GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT: item cannot be docked right
+ * @GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER: item cannot be docked at center
+ * @GDL_DOCK_ITEM_BEH_CANT_CLOSE: item cannot be closed
+ * @GDL_DOCK_ITEM_BEH_CANT_ICONIFY: item cannot be iconified
+ * @GDL_DOCK_ITEM_BEH_NO_GRIP: item doesn't have a grip
+ *
+ * Described the behaviour of a doc item. The item can have multiple flags set.
+ *
+ **/
-/* data types & structures */
typedef enum {
GDL_DOCK_ITEM_BEH_NORMAL = 0,
GDL_DOCK_ITEM_BEH_NEVER_FLOATING = 1 << 0,
@@ -59,12 +78,21 @@ typedef enum {
GDL_DOCK_ITEM_BEH_NO_GRIP = 1 << 11
} GdlDockItemBehavior;
+
+/**
+ * GdlDockItemFlags:
+ * @GDL_DOCK_IN_DRAG: item is in a drag operation
+ * @GDL_DOCK_IN_PREDRAG: item is in a predrag operation
+ * @GDL_DOCK_ICONIFIED: item is iconified
+ * @GDL_DOCK_USER_ACTION: indicates the user has started an action on the dock item
+ *
+ * Status flag of a GdlDockItem. Don't use unless you derive a widget from GdlDockItem
+ *
+ **/
typedef enum {
GDL_DOCK_IN_DRAG = 1 << GDL_DOCK_OBJECT_FLAGS_SHIFT,
GDL_DOCK_IN_PREDRAG = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 1),
GDL_DOCK_ICONIFIED = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 2),
- /* for general use: indicates the user has started an action on
- the dock item */
GDL_DOCK_USER_ACTION = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 3)
} GdlDockItemFlags;
@@ -93,20 +121,18 @@ struct _GdlDockItemClass {
gboolean has_grip;
/* virtuals */
- void (* dock_drag_begin) (GdlDockItem *item);
- void (* dock_drag_motion) (GdlDockItem *item,
- gint x,
- gint y);
- void (* dock_drag_end) (GdlDockItem *item,
- gboolean cancelled);
+ void (* dock_drag_begin) (GdlDockItem *item);
+ void (* dock_drag_motion) (GdlDockItem *item,
+ gint x,
+ gint y);
+ void (* dock_drag_end) (GdlDockItem *item,
+ gboolean cancelled);
void (* move_focus_child) (GdlDockItem *item,
GtkDirectionType direction);
-
- void (* set_orientation) (GdlDockItem *item,
- GtkOrientation orientation);
+ void (* set_orientation) (GdlDockItem *item,
+ GtkOrientation orientation);
};
-/* additional macros */
#define GDL_DOCK_ITEM_FLAGS(item) (GDL_DOCK_OBJECT (item)->flags)
#define GDL_DOCK_ITEM_IN_DRAG(item) \
((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_IN_DRAG) != 0)
@@ -163,8 +189,10 @@ void gdl_dock_item_set_orientation (GdlDockItem *item,
GtkWidget *gdl_dock_item_get_tablabel (GdlDockItem *item);
void gdl_dock_item_set_tablabel (GdlDockItem *item,
GtkWidget *tablabel);
+GtkWidget *gdl_dock_item_get_grip (GdlDockItem *item);
void gdl_dock_item_hide_grip (GdlDockItem *item);
void gdl_dock_item_show_grip (GdlDockItem *item);
+void gdl_dock_item_notify_selected (GdlDockItem *item);
/* bind and unbind items to a dock */
void gdl_dock_item_bind (GdlDockItem *item,
diff --git a/src/libgdl/gdl-dock-master.c b/src/libgdl/gdl-dock-master.c
index 1c362ed16..2bbb8eb3b 100644
--- a/src/libgdl/gdl-dock-master.c
+++ b/src/libgdl/gdl-dock-master.c
@@ -27,10 +27,11 @@
#include "gdl-i18n.h"
-#include "gdl-tools.h"
#include "gdl-dock-master.h"
#include "gdl-dock.h"
#include "gdl-dock-item.h"
+#include "gdl-dock-notebook.h"
+#include "gdl-switcher.h"
#include "libgdlmarshal.h"
#include "libgdltypebuiltins.h"
#ifdef WIN32
@@ -40,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,
@@ -126,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)
@@ -187,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);
@@ -262,6 +262,7 @@ ht_foreach_build_slist (gpointer key,
gpointer value,
GSList **slist)
{
+ (void)key;
*slist = g_slist_prepend (*slist, value);
}
@@ -320,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
@@ -481,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;
@@ -505,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);
@@ -522,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),
@@ -535,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),
@@ -718,7 +726,11 @@ item_dock_cb (GdlDockObject *object,
gpointer user_data)
{
GdlDockMaster *master = user_data;
-
+
+ (void)object;
+ (void)position;
+ (void)other_data;
+
g_return_if_fail (requestor && GDL_IS_DOCK_OBJECT (requestor));
g_return_if_fail (master && GDL_IS_DOCK_MASTER (master));
@@ -740,6 +752,8 @@ item_detach_cb (GdlDockObject *object,
{
GdlDockMaster *master = user_data;
+ (void)recursive;
+
g_return_if_fail (object && GDL_IS_DOCK_OBJECT (object));
g_return_if_fail (master && GDL_IS_DOCK_MASTER (master));
@@ -760,6 +774,8 @@ item_notify_cb (GdlDockObject *object,
gint locked = COMPUTE_LOCKED (master);
gboolean item_locked;
+ (void)pspec;
+
g_object_get (object, "locked", &item_locked, NULL);
if (item_locked) {
@@ -798,8 +814,7 @@ gdl_dock_master_add (GdlDockMaster *master,
master, object, object->name, found_object);
}
else {
- g_object_ref (object);
- gtk_object_sink (GTK_OBJECT (object));
+ g_object_ref_sink (object);
g_hash_table_insert (master->dock_objects, g_strdup (object->name), object);
}
}
diff --git a/src/libgdl/gdl-dock-master.h b/src/libgdl/gdl-dock-master.h
index 72697b484..266ca7ee4 100644
--- a/src/libgdl/gdl-dock-master.h
+++ b/src/libgdl/gdl-dock-master.h
@@ -25,7 +25,7 @@
#define __GDL_DOCK_MASTER_H__
#include <glib-object.h>
-#include <gtk/gtktypeutils.h>
+#include <gtk/gtk.h>
#include "libgdl/gdl-dock-object.h"
@@ -33,17 +33,26 @@ G_BEGIN_DECLS
/* standard macros */
#define GDL_TYPE_DOCK_MASTER (gdl_dock_master_get_type ())
-#define GDL_DOCK_MASTER(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_MASTER, GdlDockMaster))
-#define GDL_DOCK_MASTER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_MASTER, GdlDockMasterClass))
-#define GDL_IS_DOCK_MASTER(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_MASTER))
-#define GDL_IS_DOCK_MASTER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_MASTER))
-#define GDL_DOCK_MASTER_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_MASTER, GdlDockMasterClass))
+#define GDL_DOCK_MASTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_MASTER, GdlDockMaster))
+#define GDL_DOCK_MASTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_MASTER, GdlDockMasterClass))
+#define GDL_IS_DOCK_MASTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_MASTER))
+#define GDL_IS_DOCK_MASTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_MASTER))
+#define GDL_DOCK_MASTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_MASTER, GdlDockMasterClass))
/* data types & structures */
typedef struct _GdlDockMaster GdlDockMaster;
typedef struct _GdlDockMasterClass GdlDockMasterClass;
typedef struct _GdlDockMasterPrivate GdlDockMasterPrivate;
+typedef enum {
+ GDL_SWITCHER_STYLE_TEXT,
+ GDL_SWITCHER_STYLE_ICON,
+ GDL_SWITCHER_STYLE_BOTH,
+ GDL_SWITCHER_STYLE_TOOLBAR,
+ GDL_SWITCHER_STYLE_TABS,
+ GDL_SWITCHER_STYLE_NONE
+} GdlSwitcherStyle;
+
struct _GdlDockMaster {
GObject object;
diff --git a/src/libgdl/gdl-dock-notebook.c b/src/libgdl/gdl-dock-notebook.c
index 6fb931ac7..a14b9e09c 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,
@@ -60,7 +58,7 @@ static void gdl_dock_notebook_dock (GdlDockObject *object,
GValue *other_data);
static void gdl_dock_notebook_switch_page_cb (GtkNotebook *nb,
- GtkNotebookPage *page,
+ GtkWidget *page,
gint page_num,
gpointer data);
@@ -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)
@@ -157,6 +155,7 @@ gdl_dock_notebook_notify_cb (GObject *g_object,
gpointer user_data)
{
g_return_if_fail (user_data != NULL && GDL_IS_DOCK_NOTEBOOK (user_data));
+ (void)g_object;
/* chain the notify signal */
g_object_notify (G_OBJECT (user_data), pspec->name);
@@ -167,16 +166,18 @@ gdl_dock_notebook_button_cb (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
{
- if (event->type == GDK_BUTTON_PRESS)
+ (void)widget;
+ if (event->type == GDK_BUTTON_PRESS) {
GDL_DOCK_ITEM_SET_FLAGS (user_data, GDL_DOCK_USER_ACTION);
- else
+ } else {
GDL_DOCK_ITEM_UNSET_FLAGS (user_data, GDL_DOCK_USER_ACTION);
+ }
return FALSE;
}
static void
-gdl_dock_notebook_instance_init (GdlDockNotebook *notebook)
+gdl_dock_notebook_init (GdlDockNotebook *notebook)
{
GdlDockItem *item;
@@ -250,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) {
@@ -261,17 +262,18 @@ gdl_dock_notebook_destroy (GtkObject *object)
static void
gdl_dock_notebook_switch_page_cb (GtkNotebook *nb,
- GtkNotebookPage *page,
+ GtkWidget *page,
gint page_num,
gpointer data)
{
GdlDockNotebook *notebook;
GtkWidget *tablabel;
+ GdlDockItem *item;
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)));
@@ -281,7 +283,7 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook *nb,
/* activate new label */
tablabel = gtk_notebook_get_tab_label (
- nb, gtk_notebook_get_nth_page (nb, page_num));
+ nb, page);
if (tablabel && GDL_IS_DOCK_TABLABEL (tablabel))
gdl_dock_tablabel_activate (GDL_DOCK_TABLABEL (tablabel));
@@ -289,6 +291,10 @@ gdl_dock_notebook_switch_page_cb (GtkNotebook *nb,
GDL_DOCK_OBJECT (notebook)->master)
g_signal_emit_by_name (GDL_DOCK_OBJECT (notebook)->master,
"layout-changed");
+
+ /* Signal that a new dock item has been selected */
+ item = GDL_DOCK_ITEM (page);
+ gdl_dock_item_notify_selected (item);
}
static void
@@ -319,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);
@@ -332,6 +338,7 @@ gdl_dock_notebook_forall (GtkContainer *container,
static GType
gdl_dock_notebook_child_type (GtkContainer *container)
{
+ (void)container;
return GDL_TYPE_DOCK_ITEM;
}
@@ -423,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
@@ -438,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
@@ -483,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-notebook.h b/src/libgdl/gdl-dock-notebook.h
index 105da6c8c..063f53642 100644
--- a/src/libgdl/gdl-dock-notebook.h
+++ b/src/libgdl/gdl-dock-notebook.h
@@ -28,11 +28,11 @@ G_BEGIN_DECLS
/* standard macros */
#define GDL_TYPE_DOCK_NOTEBOOK (gdl_dock_notebook_get_type ())
-#define GDL_DOCK_NOTEBOOK(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_NOTEBOOK, GdlDockNotebook))
-#define GDL_DOCK_NOTEBOOK_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_NOTEBOOK, GdlDockNotebookClass))
-#define GDL_IS_DOCK_NOTEBOOK(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_NOTEBOOK))
-#define GDL_IS_DOCK_NOTEBOOK_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_NOTEBOOK))
-#define GDL_DOCK_NOTEBOOK_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_NOTEBOOK, GdlDockNotebookClass))
+#define GDL_DOCK_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_NOTEBOOK, GdlDockNotebook))
+#define GDL_DOCK_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_NOTEBOOK, GdlDockNotebookClass))
+#define GDL_IS_DOCK_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_NOTEBOOK))
+#define GDL_IS_DOCK_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_NOTEBOOK))
+#define GDL_DOCK_NOTEBOOK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_NOTEBOOK, GdlDockNotebookClass))
/* data types & structures */
typedef struct _GdlDockNotebook GdlDockNotebook;
diff --git a/src/libgdl/gdl-dock-object.c b/src/libgdl/gdl-dock-object.c
index dadf072a0..da5e08d38 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)
@@ -128,14 +126,14 @@ gdl_dock_object_class_init (GdlDockObjectClass *klass)
g_param_spec_string ("long-name", _("Long name"),
_("Human readable name for the dock object"),
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (
g_object_class, PROP_STOCK_ID,
g_param_spec_string ("stock-id", _("Stock Icon"),
_("Stock icon for the dock object"),
NULL,
- G_PARAM_READWRITE));
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (
g_object_class, PROP_PIXBUF_ICON,
@@ -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,13 +280,14 @@ 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
gdl_dock_object_foreach_detach (GdlDockObject *object,
gpointer user_data)
{
+ (void)user_data;
gdl_dock_object_detach (object, TRUE);
}
@@ -319,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
@@ -340,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
@@ -351,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
@@ -374,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);
}
@@ -395,6 +394,7 @@ gdl_dock_object_real_reduce (GdlDockObject *object)
children = gtk_container_get_children (GTK_CONTAINER (object));
if (g_list_length (children) <= 1) {
GList *l;
+ GList *dchildren = NULL;
/* detach ourselves and then re-attach our children to our
current parent. if we are not currently attached, the
@@ -402,20 +402,43 @@ gdl_dock_object_real_reduce (GdlDockObject *object)
if (parent)
gdl_dock_object_freeze (parent);
gdl_dock_object_freeze (object);
- gdl_dock_object_detach (object, FALSE);
+ /* Detach the children before detaching this object, since in this
+ * way the children can have access to the whole object hierarchy.
+ * Set the InDetach flag now, so the children know that this object
+ * is going to be detached. */
+
+
+ GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_DETACH);
+
for (l = children; l; l = l->next) {
- GdlDockObject *child = GDL_DOCK_OBJECT (l->data);
+ GdlDockObject *child;
+
+ if (!GDL_IS_DOCK_OBJECT (l->data))
+ continue;
+
+ child = GDL_DOCK_OBJECT (l->data);
g_object_ref (child);
- GDL_DOCK_OBJECT_SET_FLAGS (child, GDL_DOCK_IN_REFLOW);
gdl_dock_object_detach (child, FALSE);
+ GDL_DOCK_OBJECT_SET_FLAGS (child, GDL_DOCK_IN_REFLOW);
if (parent)
- gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (child));
+ dchildren = g_list_append (dchildren, child);
GDL_DOCK_OBJECT_UNSET_FLAGS (child, GDL_DOCK_IN_REFLOW);
- g_object_unref (child);
}
+ /* Now it can be detached */
+ gdl_dock_object_detach (object, FALSE);
+
+ /* After detaching the reduced object, we can add the
+ children (the only child in fact) to the new parent */
+ for (l = dchildren; l; l = l->next) {
+ gtk_container_add (GTK_CONTAINER (parent), l->data);
+ g_object_unref (l->data);
+ }
+ g_list_free (dchildren);
+
+
/* sink the widget, so any automatic floating widget is destroyed */
- gtk_object_sink (GTK_OBJECT (object));
+ g_object_ref_sink (object);
/* don't reenter */
object->reduce_pending = FALSE;
gdl_dock_object_thaw (object);
@@ -431,6 +454,9 @@ gdl_dock_object_dock_unimplemented (GdlDockObject *object,
GdlDockPlacement position,
GValue *other_data)
{
+ (void)requestor;
+ (void)position;
+ (void)other_data;
g_warning (_("Call to gdl_dock_object_dock in a dock object %p "
"(object type is %s) which hasn't implemented this method"),
object, G_OBJECT_TYPE_NAME (object));
@@ -440,6 +466,7 @@ static void
gdl_dock_object_real_present (GdlDockObject *object,
GdlDockObject *child)
{
+ (void)child;
gtk_widget_show (GTK_WIDGET (object));
}
@@ -464,6 +491,9 @@ gdl_dock_object_detach (GdlDockObject *object,
{
g_return_if_fail (object != NULL);
+ if (!GDL_IS_DOCK_OBJECT (object))
+ return;
+
if (!GDL_DOCK_OBJECT_ATTACHED (object))
return;
@@ -482,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;
@@ -528,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
@@ -539,13 +570,19 @@ 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;
}
+/**
+ * gdl_dock_object_dock:
+ * @object:
+ * @requestor:
+ * @position:
+ * @other_data: (allow-none):
+ **/
void
gdl_dock_object_dock (GdlDockObject *object,
GdlDockObject *requestor,
@@ -657,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)
+ return GDL_DOCK_OBJECT_GET_CLASS (object)->reorder (object, child, new_position, other_data);
+ else
+ return FALSE;
}
void
@@ -677,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);
}
/**
@@ -710,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)
+ return GDL_DOCK_OBJECT_GET_CLASS (object)->child_placement (object, child, placement);
+ else
+ return FALSE;
}
@@ -830,7 +867,7 @@ gdl_dock_param_get_type (void)
static GType our_type = 0;
if (our_type == 0) {
- GTypeInfo tinfo = { 0, };
+ GTypeInfo tinfo = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
our_type = g_type_register_static (G_TYPE_STRING, "GdlDockParam", &tinfo, 0);
/* register known transform functions */
diff --git a/src/libgdl/gdl-dock-object.h b/src/libgdl/gdl-dock-object.h
index 84e5eb9a7..d1c27ffbd 100644
--- a/src/libgdl/gdl-dock-object.h
+++ b/src/libgdl/gdl-dock-object.h
@@ -24,17 +24,17 @@
#ifndef __GDL_DOCK_OBJECT_H__
#define __GDL_DOCK_OBJECT_H__
-#include <gtk/gtkcontainer.h>
+#include <gtk/gtk.h>
G_BEGIN_DECLS
/* standard macros */
#define GDL_TYPE_DOCK_OBJECT (gdl_dock_object_get_type ())
-#define GDL_DOCK_OBJECT(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_OBJECT, GdlDockObject))
-#define GDL_DOCK_OBJECT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_OBJECT, GdlDockObjectClass))
-#define GDL_IS_DOCK_OBJECT(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_OBJECT))
-#define GDL_IS_DOCK_OBJECT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_OBJECT))
-#define GDL_DOCK_OBJECT_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_OBJECT, GdlDockObjectClass))
+#define GDL_DOCK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_OBJECT, GdlDockObject))
+#define GDL_DOCK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_OBJECT, GdlDockObjectClass))
+#define GDL_IS_DOCK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_OBJECT))
+#define GDL_IS_DOCK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_OBJECT))
+#define GDL_DOCK_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_OBJECT, GdlDockObjectClass))
/* data types & structures */
typedef enum {
@@ -221,7 +221,7 @@ GType gdl_dock_object_set_type_for_nick (const gchar *nick,
__PRETTY_FUNCTION__, \
G_OBJECT_TYPE_NAME (object), object, \
G_OBJECT (object)->ref_count, \
- (GTK_IS_OBJECT (object) && GTK_OBJECT_FLOATING (object)) ? "(float)" : "", \
+ (GTK_IS_OBJECT (object) && g_object_is_floating (object)) ? "(float)" : "", \
GDL_IS_DOCK_OBJECT (object) ? GDL_DOCK_OBJECT (object)->freeze_count : -1, \
##args); } G_STMT_END
diff --git a/src/libgdl/gdl-dock-paned.c b/src/libgdl/gdl-dock-paned.c
index 268a9f673..299384de4 100644
--- a/src/libgdl/gdl-dock-paned.c
+++ b/src/libgdl/gdl-dock-paned.c
@@ -27,17 +27,15 @@
#include "gdl-i18n.h"
#include <string.h>
-#include <gtk/gtkhpaned.h>
-#include <gtk/gtkvpaned.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);
@@ -89,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)
@@ -137,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;
@@ -206,6 +204,7 @@ gdl_dock_paned_notify_cb (GObject *g_object,
gpointer user_data)
{
GdlDockPaned *paned;
+ (void)g_object;
g_return_if_fail (user_data != NULL && GDL_IS_DOCK_PANED (user_data));
@@ -256,6 +255,7 @@ gdl_dock_paned_button_cb (GtkWidget *widget,
gpointer user_data)
{
GdlDockPaned *paned;
+ (void)widget;
g_return_val_if_fail (user_data != NULL && GDL_IS_DOCK_PANED (user_data), FALSE);
@@ -346,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);
@@ -415,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) {
@@ -429,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));
@@ -438,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;
@@ -468,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);
@@ -519,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;
@@ -530,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;
@@ -555,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;
@@ -565,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;
@@ -574,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;
@@ -605,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;
@@ -616,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;
@@ -640,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;
}
}
@@ -658,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;
@@ -678,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;
}
@@ -704,11 +709,12 @@ 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));
+ gtk_widget_show (GTK_WIDGET (requestor));
GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED);
}
}
@@ -733,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);
@@ -750,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
@@ -764,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-paned.h b/src/libgdl/gdl-dock-paned.h
index 208c9c422..06b496491 100644
--- a/src/libgdl/gdl-dock-paned.h
+++ b/src/libgdl/gdl-dock-paned.h
@@ -30,11 +30,11 @@ G_BEGIN_DECLS
/* standard macros */
#define GDL_TYPE_DOCK_PANED (gdl_dock_paned_get_type ())
-#define GDL_DOCK_PANED(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_PANED, GdlDockPaned))
-#define GDL_DOCK_PANED_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PANED, GdlDockPanedClass))
-#define GDL_IS_DOCK_PANED(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_PANED))
-#define GDL_IS_DOCK_PANED_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PANED))
-#define GDL_DOCK_PANED_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GDL_TYE_DOCK_PANED, GdlDockPanedClass))
+#define GDL_DOCK_PANED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_PANED, GdlDockPaned))
+#define GDL_DOCK_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PANED, GdlDockPanedClass))
+#define GDL_IS_DOCK_PANED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_PANED))
+#define GDL_IS_DOCK_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PANED))
+#define GDL_DOCK_PANED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYE_DOCK_PANED, GdlDockPanedClass))
/* data types & structures */
typedef struct _GdlDockPaned GdlDockPaned;
diff --git a/src/libgdl/gdl-dock-placeholder.c b/src/libgdl/gdl-dock-placeholder.c
index cd900a21d..b8fba9723 100644
--- a/src/libgdl/gdl-dock-placeholder.c
+++ b/src/libgdl/gdl-dock-placeholder.c
@@ -27,9 +27,9 @@
#include "gdl-i18n.h"
-#include "gdl-tools.h"
#include "gdl-dock-placeholder.h"
#include "gdl-dock-item.h"
+#include "gdl-dock-paned.h"
#include "gdl-dock-master.h"
#include "libgdltypebuiltins.h"
@@ -39,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,
@@ -119,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)
@@ -188,14 +186,14 @@ gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass)
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (
g_object_class, PROP_FLOAT_X,
- g_param_spec_int ("floatx", _("X-Coordinate"),
+ g_param_spec_int ("floatx", _("X Coordinate"),
_("X coordinate for dock when floating"),
-1, G_MAXINT, -1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
GDL_DOCK_PARAM_EXPORT));
g_object_class_install_property (
g_object_class, PROP_FLOAT_Y,
- g_param_spec_int ("floaty", _("Y-Coordinate"),
+ g_param_spec_int ("floaty", _("Y Coordinate"),
_("Y coordinate for dock when floating"),
-1, G_MAXINT, -1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
@@ -213,10 +211,10 @@ 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_FLAGS (ph, GTK_NO_WINDOW);
- GTK_WIDGET_UNSET_FLAGS (ph, GTK_CAN_FOCUS);
+ gtk_widget_set_has_window (GTK_WIDGET (ph), FALSE);
+ gtk_widget_set_can_focus (GTK_WIDGET (ph), FALSE);
ph->_priv = g_new0 (GdlDockPlaceholderPrivate, 1);
}
@@ -325,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
@@ -351,6 +349,7 @@ gdl_dock_placeholder_detach (GdlDockObject *object,
gboolean recursive)
{
GdlDockPlaceholder *ph = GDL_DOCK_PLACEHOLDER (object);
+ (void)recursive;
/* disconnect handlers */
disconnect_host (ph);
@@ -365,6 +364,7 @@ gdl_dock_placeholder_detach (GdlDockObject *object,
static void
gdl_dock_placeholder_reduce (GdlDockObject *object)
{
+ (void)object;
/* placeholders are not reduced */
return;
}
@@ -374,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;
@@ -389,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;
@@ -405,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 */
@@ -491,7 +498,7 @@ gdl_dock_placeholder_dock (GdlDockObject *object,
GdlDockObject *toplevel;
if (!gdl_dock_object_is_bound (GDL_DOCK_OBJECT (ph))) {
- g_warning ("%s",_("Attempt to dock a dock object to an unbound placeholder"));
+ g_warning ("%s", _("Attempt to dock a dock object to an unbound placeholder"));
return;
}
@@ -531,6 +538,8 @@ static void
gdl_dock_placeholder_present (GdlDockObject *object,
GdlDockObject *child)
{
+ (void)object;
+ (void)child;
/* do nothing */
return;
}
@@ -538,7 +547,7 @@ gdl_dock_placeholder_present (GdlDockObject *object,
/* ----- Public interface ----- */
GtkWidget *
-gdl_dock_placeholder_new (gchar *name,
+gdl_dock_placeholder_new (const gchar *name,
GdlDockObject *object,
GdlDockPlacement position,
gboolean sticky)
@@ -548,22 +557,10 @@ gdl_dock_placeholder_new (gchar *name,
ph = GDL_DOCK_PLACEHOLDER (g_object_new (GDL_TYPE_DOCK_PLACEHOLDER,
"name", name,
"sticky", sticky,
+ "next-placement", position,
+ "host", object,
NULL));
GDL_DOCK_OBJECT_UNSET_FLAGS (ph, GDL_DOCK_AUTOMATIC);
-
- if (object) {
- gdl_dock_placeholder_attach (ph, object);
- if (position == GDL_DOCK_NONE)
- position = GDL_DOCK_CENTER;
- g_object_set (G_OBJECT (ph), "next-placement", position, NULL);
- if (GDL_IS_DOCK (object)) {
- /* the top placement will be consumed by the toplevel
- dock, so add a dummy placement */
- g_object_set (G_OBJECT (ph), "next-placement", GDL_DOCK_CENTER, NULL);
- }
- /* try a recursion */
- do_excursion (ph);
- }
return GTK_WIDGET (ph);
}
@@ -573,7 +570,8 @@ gdl_dock_placeholder_weak_notify (gpointer data,
GObject *old_object)
{
GdlDockPlaceholder *ph;
-
+ (void)old_object;
+
g_return_if_fail (data != NULL && GDL_IS_DOCK_PLACEHOLDER (data));
ph = GDL_DOCK_PLACEHOLDER (data);
@@ -605,6 +603,7 @@ detach_cb (GdlDockObject *object,
{
GdlDockPlaceholder *ph;
GdlDockObject *new_host, *obj;
+ (void)recursive;
g_return_if_fail (user_data != NULL && GDL_IS_DOCK_PLACEHOLDER (user_data));
@@ -734,7 +733,9 @@ dock_cb (GdlDockObject *object,
{
GdlDockPlacement pos = GDL_DOCK_NONE;
GdlDockPlaceholder *ph;
-
+ (void)position;
+ (void)other_data;
+
g_return_if_fail (user_data != NULL && GDL_IS_DOCK_PLACEHOLDER (user_data));
ph = GDL_DOCK_PLACEHOLDER (user_data);
g_return_if_fail (ph->_priv->host == object);
diff --git a/src/libgdl/gdl-dock-placeholder.h b/src/libgdl/gdl-dock-placeholder.h
index 4a7035b82..c7e57e204 100644
--- a/src/libgdl/gdl-dock-placeholder.h
+++ b/src/libgdl/gdl-dock-placeholder.h
@@ -30,11 +30,11 @@ G_BEGIN_DECLS
/* standard macros */
#define GDL_TYPE_DOCK_PLACEHOLDER (gdl_dock_placeholder_get_type ())
-#define GDL_DOCK_PLACEHOLDER(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholder))
-#define GDL_DOCK_PLACEHOLDER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholderClass))
-#define GDL_IS_DOCK_PLACEHOLDER(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_PLACEHOLDER))
-#define GDL_IS_DOCK_PLACEHOLDER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PLACEHOLDER))
-#define GDL_DOCK_PLACEHOLDER_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholderClass))
+#define GDL_DOCK_PLACEHOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholder))
+#define GDL_DOCK_PLACEHOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholderClass))
+#define GDL_IS_DOCK_PLACEHOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_PLACEHOLDER))
+#define GDL_IS_DOCK_PLACEHOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PLACEHOLDER))
+#define GDL_DOCK_PLACEHOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholderClass))
/* data types & structures */
typedef struct _GdlDockPlaceholder GdlDockPlaceholder;
@@ -55,7 +55,7 @@ struct _GdlDockPlaceholderClass {
GType gdl_dock_placeholder_get_type (void);
-GtkWidget *gdl_dock_placeholder_new (gchar *name,
+GtkWidget *gdl_dock_placeholder_new (const gchar *name,
GdlDockObject *object,
GdlDockPlacement position,
gboolean sticky);
diff --git a/src/libgdl/gdl-dock-tablabel.c b/src/libgdl/gdl-dock-tablabel.c
index bd755893b..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;
@@ -254,6 +251,7 @@ gdl_dock_tablabel_item_notify (GObject *master,
gboolean locked;
gchar *label;
GtkBin *bin;
+ (void)pspec;
g_object_get (master,
"locked", &locked,
@@ -265,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));
@@ -280,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));
@@ -291,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
@@ -310,6 +311,7 @@ gdl_dock_tablabel_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkBin *bin;
+ GtkAllocation widget_allocation;
GdlDockTablabel *tablabel;
gint border_width;
@@ -320,22 +322,23 @@ 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_REALIZED (widget))
+ if (gtk_widget_get_realized (widget))
gdk_window_move_resize (tablabel->event_window,
allocation->x,
allocation->y,
allocation->width,
allocation->height);
- if (bin->child && GTK_WIDGET_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);
@@ -346,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);
}
}
@@ -356,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",
@@ -386,8 +391,8 @@ gdl_dock_tablabel_expose (GtkWidget *widget,
g_return_val_if_fail (GDL_IS_DOCK_TABLABEL (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
- if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) {
- GDL_CALL_PARENT_GBOOLEAN(GTK_WIDGET_CLASS, expose_event, (widget,event));
+ if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget)) {
+ GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->expose_event (widget,event);
gdl_dock_tablabel_paint (widget, event);
};
@@ -399,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);
@@ -421,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;
@@ -459,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);
};
@@ -473,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);
@@ -507,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);
};
@@ -521,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 |
@@ -540,17 +551,18 @@ 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);
+
+ gtk_widget_set_style (widget, gtk_style_attach (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget)));
- widget->style = gtk_style_attach (widget->style, widget->window);
-
- GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+ gtk_widget_set_realized (widget, TRUE);
}
static void
@@ -564,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);
}
@@ -584,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-tablabel.h b/src/libgdl/gdl-dock-tablabel.h
index 8cf3470eb..b78c1c5c7 100644
--- a/src/libgdl/gdl-dock-tablabel.h
+++ b/src/libgdl/gdl-dock-tablabel.h
@@ -32,11 +32,11 @@ G_BEGIN_DECLS
/* standard macros */
#define GDL_TYPE_DOCK_TABLABEL (gdl_dock_tablabel_get_type ())
-#define GDL_DOCK_TABLABEL(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK_TABLABEL, GdlDockTablabel))
-#define GDL_DOCK_TABLABEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_TABLABEL, GdlDockTablabelClass))
-#define GDL_IS_DOCK_TABLABEL(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK_TABLABEL))
-#define GDL_IS_DOCK_TABLABEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_TABLABEL))
-#define GDL_DOCK_TABLABEL_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK_TABLABEL, GdlDockTablabelClass))
+#define GDL_DOCK_TABLABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_TABLABEL, GdlDockTablabel))
+#define GDL_DOCK_TABLABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_TABLABEL, GdlDockTablabelClass))
+#define GDL_IS_DOCK_TABLABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_TABLABEL))
+#define GDL_IS_DOCK_TABLABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_TABLABEL))
+#define GDL_DOCK_TABLABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_TABLABEL, GdlDockTablabelClass))
/* data types & structures */
typedef struct _GdlDockTablabel GdlDockTablabel;
diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c
index 7c74791db..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,
@@ -79,7 +77,7 @@ static void gdl_dock_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
-static GtkType gdl_dock_child_type (GtkContainer *container);
+static GType gdl_dock_child_type (GtkContainer *container);
static void gdl_dock_detach (GdlDockObject *object,
gboolean recursive);
@@ -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,9 +256,9 @@ gdl_dock_class_init (GdlDockClass *klass)
}
static void
-gdl_dock_instance_init (GdlDock *dock)
+gdl_dock_init (GdlDock *dock)
{
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (dock), GTK_NO_WINDOW);
+ gtk_widget_set_has_window (GTK_WIDGET (dock), FALSE);
dock->root = NULL;
dock->_priv = g_new0 (GdlDockPrivate, 1);
@@ -275,6 +273,8 @@ gdl_dock_floating_configure_event_cb (GtkWidget *widget,
{
GdlDock *dock;
+ (void)widget;
+
g_return_val_if_fail (user_data != NULL && GDL_IS_DOCK (user_data), TRUE);
dock = GDL_DOCK (user_data);
@@ -292,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) {
@@ -314,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);
@@ -335,42 +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);
-
- /* set transient for the first dock if that is a non-floating dock */
- controller = gdl_dock_master_get_controller (master);
- if (controller && GDL_IS_DOCK (controller)) {
- gboolean first_is_floating;
- g_object_get (controller, "floating", &first_is_floating, NULL);
- if (!first_is_floating) {
- GtkWidget *toplevel =
- gtk_widget_get_toplevel (GTK_WIDGET (controller));
-
- if (GTK_IS_WINDOW (toplevel))
- gtk_window_set_transient_for (GTK_WINDOW (dock->_priv->window),
- GTK_WINDOW (toplevel));
- }
- }
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;
}
@@ -473,7 +455,6 @@ gdl_dock_set_title (GdlDock *dock)
{
GdlDockObject *object = GDL_DOCK_OBJECT (dock);
gchar *title = NULL;
- gboolean free_title = FALSE;
if (!dock->_priv->window)
return;
@@ -483,25 +464,22 @@ gdl_dock_set_title (GdlDock *dock)
}
else if (object->master) {
g_object_get (object->master, "default-title", &title, NULL);
- free_title = TRUE;
}
if (!title && dock->root) {
g_object_get (dock->root, "long-name", &title, NULL);
- free_title = TRUE;
}
if (!title) {
/* set a default title in the long_name */
dock->_priv->auto_title = TRUE;
- free_title = FALSE;
- title = object->long_name = g_strdup_printf (
+ title = g_strdup_printf (
_("Dock #%d"), GDL_DOCK_MASTER (object->master)->dock_number++);
}
gtk_window_set_title (GTK_WINDOW (dock->_priv->window), title);
- if (free_title)
- g_free (title);
+
+ g_free (title);
}
static void
@@ -510,12 +488,22 @@ gdl_dock_notify_cb (GObject *object,
gpointer user_data)
{
GdlDock *dock;
-
+ gchar* long_name;
+
+ (void)pspec;
+ (void)user_data;
+
g_return_if_fail (object != NULL || GDL_IS_DOCK (object));
-
- dock = GDL_DOCK (object);
- dock->_priv->auto_title = FALSE;
- gdl_dock_set_title (dock);
+
+ g_object_get (object, "long-name", &long_name, NULL);
+
+ if (long_name)
+ {
+ dock = GDL_DOCK (object);
+ dock->_priv->auto_title = FALSE;
+ gdl_dock_set_title (dock);
+ }
+ g_free (long_name);
}
static void
@@ -542,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
@@ -558,10 +546,10 @@ 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_VISIBLE (dock->root))
+ if (dock->root && gtk_widget_get_visible (GTK_WIDGET (dock->root)))
gtk_widget_size_request (GTK_WIDGET (dock->root), requisition);
else {
requisition->width = 0;
@@ -571,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
@@ -587,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;
@@ -597,7 +585,7 @@ gdl_dock_size_allocate (GtkWidget *widget,
allocation->width = MAX (1, allocation->width - 2 * border_width);
allocation->height = MAX (1, allocation->height - 2 * border_width);
- if (dock->root && GTK_WIDGET_VISIBLE (dock->root))
+ if (dock->root && gtk_widget_get_visible (GTK_WIDGET (dock->root)))
gtk_widget_size_allocate (GTK_WIDGET (dock->root), allocation);
}
@@ -612,11 +600,11 @@ 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);
- if (GTK_WIDGET_VISIBLE (child) && !GTK_WIDGET_MAPPED (child))
+ if (gtk_widget_get_visible (child) && !gtk_widget_get_mapped (child))
gtk_widget_map (child);
}
}
@@ -632,11 +620,11 @@ 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);
- if (GTK_WIDGET_VISIBLE (child) && GTK_WIDGET_MAPPED (child))
+ if (gtk_widget_get_visible (child) && gtk_widget_get_mapped (child))
gtk_widget_unmap (child);
}
@@ -662,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)
@@ -683,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)
@@ -720,14 +708,14 @@ gdl_dock_remove (GtkContainer *container,
g_return_if_fail (widget != NULL);
dock = GDL_DOCK (container);
- was_visible = GTK_WIDGET_VISIBLE (widget);
+ was_visible = gtk_widget_get_visible (widget);
if (GTK_WIDGET (dock->root) == widget) {
dock->root = NULL;
GDL_DOCK_OBJECT_UNSET_FLAGS (widget, GDL_DOCK_ATTACHED);
gtk_widget_unparent (widget);
- if (was_visible && GTK_WIDGET_VISIBLE (GTK_WIDGET (container)))
+ if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container)))
gtk_widget_queue_resize (GTK_WIDGET (dock));
}
}
@@ -740,6 +728,8 @@ gdl_dock_forall (GtkContainer *container,
{
GdlDock *dock;
+ (void)include_internals;
+
g_return_if_fail (container != NULL);
g_return_if_fail (GDL_IS_DOCK (container));
g_return_if_fail (callback != NULL);
@@ -750,9 +740,10 @@ gdl_dock_forall (GtkContainer *container,
(*callback) (GTK_WIDGET (dock->root), callback_data);
}
-static GtkType
+static GType
gdl_dock_child_type (GtkContainer *container)
{
+ (void)container;
return GDL_TYPE_DOCK_ITEM;
}
@@ -773,6 +764,7 @@ static void
gdl_dock_reduce (GdlDockObject *object)
{
GdlDock *dock = GDL_DOCK (object);
+ GtkWidget *parent;
if (dock->root)
return;
@@ -786,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);
}
}
}
@@ -801,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;
@@ -812,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. */
@@ -847,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;
@@ -927,15 +920,15 @@ gdl_dock_dock (GdlDockObject *object,
/* Realize the item (create its corresponding GdkWindow) when
GdlDock has been realized. */
- if (GTK_WIDGET_REALIZED (dock))
+ if (gtk_widget_get_realized (GTK_WIDGET (dock)))
gtk_widget_realize (widget);
-
+
/* Map the widget if it's visible and the parent is visible and has
been mapped. This is done to make sure that the GdkWindow is
visible. */
- if (GTK_WIDGET_VISIBLE (dock) &&
- GTK_WIDGET_VISIBLE (widget)) {
- if (GTK_WIDGET_MAPPED (dock))
+ if (gtk_widget_get_visible (GTK_WIDGET (dock)) &&
+ gtk_widget_get_visible (widget)) {
+ if (gtk_widget_get_mapped (GTK_WIDGET (dock)))
gtk_widget_map (widget);
/* Make the widget resize. */
@@ -1023,8 +1016,11 @@ gdl_dock_present (GdlDockObject *object,
{
GdlDock *dock = GDL_DOCK (object);
- if (dock->_priv->floating)
+ (void)child;
+
+ if (dock->_priv->floating) {
gtk_window_present (GTK_WINDOW (dock->_priv->window));
+ }
}
@@ -1067,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;
}
}
@@ -1097,6 +1096,8 @@ gdl_dock_select_larger_item (GdlDockItem *dock_item_1,
gint level /* for debugging */)
{
GtkRequisition size_1, size_2;
+
+ (void)level;
g_return_val_if_fail (dock_item_1 != NULL, dock_item_2);
g_return_val_if_fail (dock_item_2 != NULL, dock_item_1);
@@ -1124,6 +1125,8 @@ gdl_dock_select_larger_item (GdlDockItem *dock_item_1,
return ((size_1.width * size_1.height)
>= (size_2.width * size_2.height)?
dock_item_1 : dock_item_2);
+ } else if (placement == GDL_DOCK_NONE) {
+ return dock_item_1;
} else {
g_warning ("Should not reach here: %s:%d", __FUNCTION__, __LINE__);
}
@@ -1218,7 +1221,7 @@ gdl_dock_add_item (GdlDock *dock,
/* Non-floating item. */
if (dock->root) {
GdlDockPlacement local_placement;
- GtkRequisition preferred_size;
+ /* GtkRequisition preferred_size; */
best_dock_item =
gdl_dock_find_best_placement_item (GDL_DOCK_ITEM (dock->root),
@@ -1258,9 +1261,9 @@ gdl_dock_add_floating_item (GdlDock *dock,
"floaty", y,
NULL));
- if (GTK_WIDGET_VISIBLE (dock)) {
+ if (gtk_widget_get_visible (GTK_WIDGET (dock))) {
gtk_widget_show (GTK_WIDGET (new_dock));
- if (GTK_WIDGET_MAPPED (dock))
+ if (gtk_widget_get_mapped (GTK_WIDGET (dock)))
gtk_widget_map (GTK_WIDGET (new_dock));
/* Make the widget resize. */
@@ -1330,18 +1333,19 @@ gdl_dock_xor_rect (GdlDock *dock,
GdkRectangle *rect)
{
GtkWidget *widget;
+ GdkWindow *window;
gint8 dash_list [2];
widget = GTK_WIDGET (dock);
if (!dock->_priv->xor_gc) {
- if (GTK_WIDGET_REALIZED (widget)) {
+ if (gtk_widget_get_realized (widget)) {
GdkGCValues values;
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;
};
@@ -1350,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-dock.h b/src/libgdl/gdl-dock.h
index 7508feef7..2259d395d 100644
--- a/src/libgdl/gdl-dock.h
+++ b/src/libgdl/gdl-dock.h
@@ -31,11 +31,11 @@ G_BEGIN_DECLS
/* standard macros */
#define GDL_TYPE_DOCK (gdl_dock_get_type ())
-#define GDL_DOCK(obj) (GTK_CHECK_CAST ((obj), GDL_TYPE_DOCK, GdlDock))
-#define GDL_DOCK_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK, GdlDockClass))
-#define GDL_IS_DOCK(obj) (GTK_CHECK_TYPE ((obj), GDL_TYPE_DOCK))
-#define GDL_IS_DOCK_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK))
-#define GDL_DOCK_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_DOCK, GdlDockClass))
+#define GDL_DOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK, GdlDock))
+#define GDL_DOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK, GdlDockClass))
+#define GDL_IS_DOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK))
+#define GDL_IS_DOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK))
+#define GDL_DOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK, GdlDockClass))
/* data types & structures */
typedef struct _GdlDock GdlDock;
diff --git a/src/libgdl/gdl-stock.c b/src/libgdl/gdl-stock.c
deleted file mode 100644
index 94f825678..000000000
--- a/src/libgdl/gdl-stock.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- * gdl-stock.c
- *
- * Copyright (C) 2003 Jeroen Zwartepoorte
- *
- *
- * 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
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gtk/gtk.h>
-#include <gtk/gtkiconfactory.h>
-#include "gdl-stock.h"
-#include "gdl-stock-icons.h"
-
-static GtkIconFactory *gdl_stock_factory = NULL;
-
-static struct {
- const gchar *stock_id;
- const guint8 *icon_data;
- const guint data_size;
-}
-gdl_icons[] =
-{
- { GDL_STOCK_CLOSE, stock_close_icon, sizeof (stock_close_icon) },
- { GDL_STOCK_MENU_LEFT, stock_menu_left_icon, sizeof (stock_menu_left_icon) },
- { GDL_STOCK_MENU_RIGHT, stock_menu_right_icon, sizeof (stock_menu_right_icon) }
-};
-
-static void
-icon_set_from_data (GtkIconSet *set,
- const guint8 *icon_data,
- const guint data_size,
- GtkIconSize size,
- gboolean fallback)
-{
- GtkIconSource *source;
- GdkPixbuf *pixbuf;
- GError *err = NULL;
-
- source = gtk_icon_source_new ();
-
- gtk_icon_source_set_size (source, size);
- gtk_icon_source_set_size_wildcarded (source, FALSE);
-
- pixbuf = gdk_pixbuf_new_from_inline (data_size, icon_data, FALSE, &err);
- if (err) {
- g_warning ("%s",err->message);
- g_error_free (err);
- err = NULL;
- g_object_unref (source);
- return;
- }
-
- gtk_icon_source_set_pixbuf (source, pixbuf);
-
- g_object_unref (pixbuf);
-
- gtk_icon_set_add_source (set, source);
-
- if (fallback) {
- gtk_icon_source_set_size_wildcarded (source, TRUE);
- gtk_icon_set_add_source (set, source);
- }
-
- gtk_icon_source_free (source);
-}
-
-static void
-add_icon (GtkIconFactory *factory,
- const gchar *stock_id,
- const guint8 *icon_data,
- const guint data_size)
-{
- GtkIconSet *set;
- gboolean fallback = FALSE;
-
- set = gtk_icon_factory_lookup (factory, stock_id);
-
- if (!set) {
- set = gtk_icon_set_new ();
- gtk_icon_factory_add (factory, stock_id, set);
- gtk_icon_set_unref (set);
-
- fallback = TRUE;
- }
-
- icon_set_from_data (set, icon_data, data_size, GTK_ICON_SIZE_MENU, fallback);
-}
-
-void
-gdl_stock_init (void)
-{
- static gboolean initialized = FALSE;
- gint i;
-
- if (initialized)
- return;
-
- gdl_stock_factory = gtk_icon_factory_new ();
-
- for (i = 0; i < G_N_ELEMENTS (gdl_icons); i++) {
- add_icon (gdl_stock_factory,
- gdl_icons[i].stock_id,
- gdl_icons[i].icon_data,
- gdl_icons[i].data_size);
- }
-
- gtk_icon_factory_add_default (gdl_stock_factory);
-
- initialized = TRUE;
-}
diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c
index 43768bbdf..183ae66c0 100644
--- a/src/libgdl/gdl-switcher.c
+++ b/src/libgdl/gdl-switcher.c
@@ -4,20 +4,22 @@
* Copyright (C) 2003 Ettore Perazzoli,
* 2007 Naba Kumar
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * 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
- * General Public License for more details.
+ * Library General Public License for more details.
*
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
+ *
* Copied and adapted from ESidebar.[ch] from evolution
*
* Authors: Ettore Perazzoli <ettore@ximian.com>
@@ -30,19 +32,10 @@
#include "gdl-i18n.h"
#include "gdl-switcher.h"
-#include "gdl-tools.h"
#include "libgdlmarshal.h"
#include "libgdltypebuiltins.h"
#include <gtk/gtk.h>
-#include <gtk/gtkhbox.h>
-#include <gtk/gtkimage.h>
-#include <gtk/gtklabel.h>
-#include <gtk/gtktogglebutton.h>
-
-#if HAVE_GNOME
-#include <gconf/gconf-client.h>
-#endif
static void gdl_switcher_set_property (GObject *object,
guint prop_id,
@@ -58,8 +51,9 @@ static void gdl_switcher_add_button (GdlSwitcher *switcher,
const gchar *tooltips,
const gchar *stock_id,
const GdkPixbuf *pixbuf_icon,
- gint switcher_id);
-static void gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id);
+ gint switcher_id,
+ GtkWidget *page);
+/* static void gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id); */
static void gdl_switcher_select_page (GdlSwitcher *switcher, gint switcher_id);
static void gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id);
static void gdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show);
@@ -78,7 +72,7 @@ typedef struct {
GtkWidget *icon;
GtkWidget *arrow;
GtkWidget *hbox;
- GtkTooltips *tooltips;
+ GtkWidget *page;
int id;
} Button;
@@ -94,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 : \
@@ -105,9 +99,36 @@ GDL_CLASS_BOILERPLATE (GdlSwitcher, gdl_switcher, GtkNotebook, GTK_TYPE_NOTEBOOK
/* Utility functions. */
+static void
+gdl_switcher_long_name_changed (GObject* object,
+ GParamSpec* spec,
+ gpointer user_data)
+{
+ Button* button = user_data;
+ gchar* label;
+
+ g_object_get (object, "long-name", &label, NULL);
+ gtk_label_set_text (GTK_LABEL (button->label), label);
+ g_free (label);
+}
+
+static void
+gdl_switcher_stock_id_changed (GObject* object,
+ GParamSpec* spec,
+ gpointer user_data)
+{
+ Button* button = user_data;
+ gchar* id;
+
+ g_object_get (object, "stock-id", &id, NULL);
+ gtk_image_set_from_stock (GTK_IMAGE(button->icon), id, GTK_ICON_SIZE_MENU);
+ g_free (id);
+}
+
+
static Button *
button_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon,
- GtkTooltips *tooltips, GtkWidget *arrow, GtkWidget *hbox, int id)
+ GtkWidget *arrow, GtkWidget *hbox, int id, GtkWidget *page)
{
Button *button = g_new (Button, 1);
@@ -116,15 +137,19 @@ button_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon,
button->icon = icon;
button->arrow = arrow;
button->hbox = hbox;
- button->tooltips = tooltips;
button->id = id;
+ button->page = page;
+ g_signal_connect (page, "notify::long-name", G_CALLBACK (gdl_switcher_long_name_changed),
+ button);
+ g_signal_connect (page, "notify::stock-id", G_CALLBACK (gdl_switcher_stock_id_changed),
+ button);
+
g_object_ref (button_widget);
g_object_ref (label);
g_object_ref (icon);
g_object_ref (arrow);
g_object_ref (hbox);
- g_object_ref (tooltips);
return button;
}
@@ -132,11 +157,17 @@ button_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon,
static void
button_free (Button *button)
{
+ g_signal_handlers_disconnect_by_func (button->page,
+ gdl_switcher_long_name_changed,
+ button);
+ g_signal_handlers_disconnect_by_func (button->page,
+ gdl_switcher_stock_id_changed,
+ button);
+
g_object_unref (button->button_widget);
g_object_unref (button->label);
g_object_unref (button->icon);
g_object_unref (button->hbox);
- g_object_unref (button->tooltips);
g_free (button);
}
@@ -224,8 +255,8 @@ button_toggled_callback (GtkToggleButton *toggle_button,
static int
layout_buttons (GdlSwitcher *switcher)
{
- GtkRequisition client_requisition;
- GtkAllocation *allocation = & GTK_WIDGET (switcher)->allocation;
+ GtkRequisition client_requisition = {0,};
+ GtkAllocation allocation;
GdlSwitcherStyle switcher_style;
gboolean icons_only;
int num_btns = g_slist_length (switcher->priv->buttons);
@@ -240,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;
@@ -268,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;
}
@@ -348,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 */
@@ -356,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;
@@ -400,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. */
@@ -432,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;
@@ -464,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. */
@@ -477,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;
@@ -505,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));
}
@@ -521,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
@@ -537,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. */
@@ -597,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
@@ -607,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 */
@@ -616,22 +646,17 @@ static void
gdl_switcher_notify_cb (GObject *g_object, GParamSpec *pspec,
GdlSwitcher *switcher)
{
- gboolean show_tabs;
- g_return_if_fail (switcher != NULL && GDL_IS_SWITCHER (switcher));
- show_tabs = gtk_notebook_get_show_tabs (GTK_NOTEBOOK (switcher));
- gdl_switcher_set_show_buttons (switcher, !show_tabs);
}
static void
-gdl_switcher_switch_page_cb (GtkNotebook *nb, GtkNotebookPage *page,
+gdl_switcher_switch_page_cb (GtkNotebook *nb, GtkWidget *page_widget,
gint page_num, GdlSwitcher *switcher)
{
- GtkWidget *page_widget;
- GtkWidget *tablabel;
gint switcher_id;
-
+
+ (void)nb;
+ (void)page_num;
/* Change switcher button */
- page_widget = gtk_notebook_get_nth_page (nb, page_num);
switcher_id = gdl_switcher_get_page_id (page_widget);
gdl_switcher_select_button (GDL_SWITCHER (switcher), switcher_id);
}
@@ -641,11 +666,13 @@ gdl_switcher_page_added_cb (GtkNotebook *nb, GtkWidget *page,
gint page_num, GdlSwitcher *switcher)
{
gint switcher_id;
-
+
+ (void)nb;
+ (void)page_num;
switcher_id = gdl_switcher_get_page_id (page);
gdl_switcher_add_button (GDL_SWITCHER (switcher), NULL, NULL, NULL, NULL,
- switcher_id);
+ switcher_id, page);
gdl_switcher_select_button (GDL_SWITCHER (switcher), switcher_id);
}
@@ -683,7 +710,6 @@ gdl_switcher_select_page (GdlSwitcher *switcher, gint id)
static void
gdl_switcher_class_init (GdlSwitcherClass *klass)
{
- GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -708,14 +734,23 @@ gdl_switcher_class_init (GdlSwitcherClass *klass)
GDL_TYPE_SWITCHER_STYLE,
GDL_SWITCHER_STYLE_BOTH,
G_PARAM_READWRITE));
+
+ gtk_rc_parse_string ("style \"gdl-button-style\"\n"
+ "{\n"
+ "GtkWidget::focus-padding = 1\n"
+ "GtkWidget::focus-line-width = 1\n"
+ "xthickness = 0\n"
+ "ythickness = 0\n"
+ "}\n"
+ "widget \"*.gdl-button\" style \"gdl-button-style\"");
}
static void
-gdl_switcher_instance_init (GdlSwitcher *switcher)
+gdl_switcher_init (GdlSwitcher *switcher)
{
GdlSwitcherPrivate *priv;
- GTK_WIDGET_SET_FLAGS (switcher, GTK_NO_WINDOW);
+ gtk_widget_set_has_window (GTK_WIDGET (switcher), FALSE);
priv = g_new0 (GdlSwitcherPrivate, 1);
switcher->priv = priv;
@@ -747,16 +782,19 @@ gdl_switcher_new (void)
void
gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label,
const gchar *tooltips, const gchar *stock_id,
- const GdkPixbuf *pixbuf_icon, gint switcher_id)
+ const GdkPixbuf *pixbuf_icon,
+ gint switcher_id, GtkWidget* page)
{
+ GtkWidget *event_box;
GtkWidget *button_widget;
GtkWidget *hbox;
GtkWidget *icon_widget;
GtkWidget *label_widget;
GtkWidget *arrow;
- GtkTooltips *button_tooltips;
button_widget = gtk_toggle_button_new ();
+ gtk_widget_set_name (button_widget, "gdl-button");
+ gtk_button_set_relief (GTK_BUTTON(button_widget), GTK_RELIEF_HALF);
if (switcher->priv->show)
gtk_widget_show (button_widget);
g_signal_connect (button_widget, "toggled",
@@ -767,12 +805,13 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label,
gtk_container_add (GTK_CONTAINER (button_widget), hbox);
gtk_widget_show (hbox);
- if (stock_id)
- icon_widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
- else if (pixbuf_icon)
+ if (stock_id) {
+ icon_widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU);
+ } else if (pixbuf_icon) {
icon_widget = gtk_image_new_from_pixbuf (pixbuf_icon);
- else
- icon_widget = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_BUTTON);
+ } else {
+ icon_widget = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_MENU);
+ }
gtk_widget_show (icon_widget);
@@ -785,24 +824,22 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label,
}
gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5);
gtk_widget_show (label_widget);
- button_tooltips = gtk_tooltips_new();
- gtk_tooltips_set_tip (GTK_TOOLTIPS (button_tooltips), button_widget,
- tooltips, NULL);
-
+
+
+ gtk_widget_set_tooltip_text (button_widget,
+ tooltips);
+
switch (INTERNAL_MODE (switcher)) {
case GDL_SWITCHER_STYLE_TEXT:
gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
- gtk_tooltips_disable (button_tooltips);
break;
case GDL_SWITCHER_STYLE_ICON:
gtk_box_pack_start (GTK_BOX (hbox), icon_widget, TRUE, TRUE, 0);
- gtk_tooltips_enable (button_tooltips);
break;
case GDL_SWITCHER_STYLE_BOTH:
default:
gtk_box_pack_start (GTK_BOX (hbox), icon_widget, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0);
- gtk_tooltips_disable (button_tooltips);
break;
}
arrow = gtk_arrow_new (GTK_ARROW_UP, GTK_SHADOW_NONE);
@@ -812,13 +849,14 @@ gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label,
switcher->priv->buttons =
g_slist_append (switcher->priv->buttons,
button_new (button_widget, label_widget,
- icon_widget, button_tooltips,
- arrow, hbox, switcher_id));
+ icon_widget,
+ arrow, hbox, switcher_id, page));
+
gtk_widget_set_parent (button_widget, GTK_WIDGET (switcher));
-
gtk_widget_queue_resize (GTK_WIDGET (switcher));
}
+#if 0
static void
gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id)
{
@@ -836,6 +874,7 @@ gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id)
}
gtk_widget_queue_resize (GTK_WIDGET (switcher));
}
+#endif
static void
gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id)
@@ -845,6 +884,7 @@ gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id)
/* Select the notebook page associated with this button */
gdl_switcher_select_page (switcher, switcher_id);
}
+
gint
gdl_switcher_insert_page (GdlSwitcher *switcher, GtkWidget *page,
@@ -863,192 +903,99 @@ gdl_switcher_insert_page (GdlSwitcher *switcher, GtkWidget *page,
gtk_widget_show (tab_widget);
}
switcher_id = gdl_switcher_get_page_id (page);
- gdl_switcher_add_button (switcher, label, tooltips, stock_id, pixbuf_icon, switcher_id);
+ gdl_switcher_add_button (switcher, label, tooltips, stock_id, pixbuf_icon, switcher_id, page);
+
ret_position = gtk_notebook_insert_page (GTK_NOTEBOOK (switcher), page,
tab_widget, position);
g_signal_handlers_unblock_by_func (switcher,
gdl_switcher_page_added_cb,
switcher);
+
return ret_position;
}
static void
-set_switcher_style_internal (GdlSwitcher *switcher,
- GdlSwitcherStyle switcher_style )
+set_switcher_style_toolbar (GdlSwitcher *switcher,
+ GdlSwitcherStyle switcher_style)
{
GSList *p;
- if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
- switcher->priv->show == FALSE)
+ if (switcher_style == GDL_SWITCHER_STYLE_NONE
+ || switcher_style == GDL_SWITCHER_STYLE_TABS)
return;
- if (switcher_style == GDL_SWITCHER_STYLE_TABS)
- {
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), TRUE);
- return;
- }
-
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE);
-
+ if (switcher_style == GDL_SWITCHER_STYLE_TOOLBAR)
+ switcher_style = GDL_SWITCHER_STYLE_BOTH;
+
if (switcher_style == INTERNAL_MODE (switcher))
return;
-
+
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE);
+
for (p = switcher->priv->buttons; p != NULL; p = p->next) {
Button *button = p->data;
gtk_container_remove (GTK_CONTAINER (button->hbox), button->arrow);
+
+ if (gtk_widget_get_parent (button->icon))
+ gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon);
+ if (gtk_widget_get_parent (button->label))
+ gtk_container_remove (GTK_CONTAINER (button->hbox), button->label);
+
switch (switcher_style) {
case GDL_SWITCHER_STYLE_TEXT:
- gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon);
- if (INTERNAL_MODE (switcher)
- == GDL_SWITCHER_STYLE_ICON) {
- gtk_box_pack_start (GTK_BOX (button->hbox), button->label,
- TRUE, TRUE, 0);
- gtk_widget_show (button->label);
- gtk_tooltips_disable (button->tooltips);
- }
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->label,
+ TRUE, TRUE, 0);
+ gtk_widget_show (button->label);
break;
+
case GDL_SWITCHER_STYLE_ICON:
- gtk_container_remove(GTK_CONTAINER (button->hbox), button->label);
- if (INTERNAL_MODE (switcher)
- == GDL_SWITCHER_STYLE_TEXT) {
- gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
- TRUE, TRUE, 0);
- gtk_widget_show (button->icon);
- } else
- gtk_container_child_set (GTK_CONTAINER (button->hbox),
- button->icon, "expand", TRUE, NULL);
- gtk_tooltips_enable (button->tooltips);
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
+ TRUE, TRUE, 0);
+ gtk_widget_show (button->icon);
break;
- case GDL_SWITCHER_STYLE_BOTH:
- if (INTERNAL_MODE (switcher)
- == GDL_SWITCHER_STYLE_TEXT) {
- gtk_container_remove (GTK_CONTAINER (button->hbox),
- button->label);
- gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
- FALSE, TRUE, 0);
- gtk_widget_show (button->icon);
- } else {
- gtk_container_child_set (GTK_CONTAINER (button->hbox),
- button->icon, "expand", FALSE, NULL);
- }
- gtk_tooltips_disable (button->tooltips);
- gtk_box_pack_start (GTK_BOX (button->hbox), button->label, TRUE,
- TRUE, 0);
+ case GDL_SWITCHER_STYLE_BOTH:
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->icon,
+ FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->label,
+ TRUE, TRUE, 0);
+ gtk_widget_show (button->icon);
gtk_widget_show (button->label);
break;
+
default:
break;
}
- gtk_box_pack_start (GTK_BOX (button->hbox), button->arrow, FALSE,
- FALSE, 0);
- }
-}
-
-#if HAVE_GNOME
-static GConfEnumStringPair toolbar_styles[] = {
- { GDL_SWITCHER_STYLE_TEXT, "text" },
- { GDL_SWITCHER_STYLE_ICON, "icons" },
- { GDL_SWITCHER_STYLE_BOTH, "both" },
- { GDL_SWITCHER_STYLE_BOTH, "both-horiz" },
- { GDL_SWITCHER_STYLE_BOTH, "both_horiz" },
- { -1, NULL }
-};
-
-static void
-style_changed_notify (GConfClient *gconf, guint id, GConfEntry *entry,
- void *data)
-{
- GdlSwitcher *switcher = data;
- char *val;
- int switcher_style;
-
- val = gconf_client_get_string (gconf,
- "/desktop/gnome/interface/toolbar_style",
- NULL);
- if (val == NULL || !gconf_string_to_enum (toolbar_styles, val,
- &switcher_style))
- switcher_style = GDL_SWITCHER_STYLE_BOTH;
- g_free(val);
- set_switcher_style_internal (GDL_SWITCHER (switcher), switcher_style);
- switcher->priv->toolbar_style = switcher_style;
+ gtk_box_pack_start (GTK_BOX (button->hbox), button->arrow,
+ FALSE, FALSE, 0);
+ }
- gtk_widget_queue_resize (GTK_WIDGET (switcher));
+ gdl_switcher_set_show_buttons (switcher, TRUE);
}
static void
gdl_switcher_set_style (GdlSwitcher *switcher, GdlSwitcherStyle switcher_style)
{
- GConfClient *gconf_client = gconf_client_get_default ();
-
- if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
- switcher->priv->show == FALSE)
- return;
-
- if (switcher->priv->switcher_style == switcher_style &&
- switcher->priv->show == TRUE)
+ if (switcher->priv->switcher_style == switcher_style)
return;
- if (switcher->priv->switcher_style == GDL_SWITCHER_STYLE_TOOLBAR) {
- if (switcher->priv->style_changed_id) {
- gconf_client_notify_remove (gconf_client,
- switcher->priv->style_changed_id);
- switcher->priv->style_changed_id = 0;
- }
+ if (switcher_style == GDL_SWITCHER_STYLE_NONE) {
+ gdl_switcher_set_show_buttons (switcher, FALSE);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE);
}
-
- if (switcher_style != GDL_SWITCHER_STYLE_TOOLBAR) {
- set_switcher_style_internal (switcher, switcher_style);
-
- gtk_widget_queue_resize (GTK_WIDGET (switcher));
- } else {
- /* This is a little bit tricky, toolbar style is more
- * of a meta-style where the actual style is dictated by
- * the gnome toolbar setting, so that is why we have
- * the is_toolbar_style bool - it tracks the toolbar
- * style while the switcher_style member is the actual look and
- * feel */
- switcher->priv->style_changed_id =
- gconf_client_notify_add (gconf_client,
- "/desktop/gnome/interface/toolbar_style",
- style_changed_notify, switcher,
- NULL, NULL);
- style_changed_notify (gconf_client, 0, NULL, switcher);
+ else if (switcher_style == GDL_SWITCHER_STYLE_TABS) {
+ gdl_switcher_set_show_buttons (switcher, FALSE);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), TRUE);
}
-
- g_object_unref (gconf_client);
-
- if (switcher_style != GDL_SWITCHER_STYLE_TABS)
- switcher->priv->switcher_style = switcher_style;
-}
-
-#else /* HAVE_GNOME */
-
-static void
-gdl_switcher_set_style (GdlSwitcher *switcher, GdlSwitcherStyle switcher_style)
-{
- if (switcher_style == GDL_SWITCHER_STYLE_TABS &&
- switcher->priv->show == FALSE)
- return;
-
- if (switcher->priv->switcher_style == switcher_style &&
- switcher->priv->show == TRUE)
- return;
+ else
+ set_switcher_style_toolbar (switcher, switcher_style);
- set_switcher_style_internal (switcher,
- ((switcher_style ==
- GDL_SWITCHER_STYLE_TOOLBAR)?
- GDL_SWITCHER_STYLE_BOTH : switcher_style));
gtk_widget_queue_resize (GTK_WIDGET (switcher));
-
- if (switcher_style != GDL_SWITCHER_STYLE_TABS)
- switcher->priv->switcher_style = switcher_style;
+ switcher->priv->switcher_style = switcher_style;
}
-#endif /* HAVE_GNOME */
-
static void
gdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show)
{
diff --git a/src/libgdl/gdl-switcher.h b/src/libgdl/gdl-switcher.h
index be4b179bf..991f2da20 100644
--- a/src/libgdl/gdl-switcher.h
+++ b/src/libgdl/gdl-switcher.h
@@ -4,20 +4,22 @@
* Copyright (C) 2003 Ettore Perazzoli
* 2007 Naba Kumar
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
+* This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * 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
- * General Public License for more details.
+ * Library General Public License for more details.
*
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
+ *
* Authors: Ettore Perazzoli <ettore@ximian.com>
* Naba Kumar <naba@gnome.org>
*/
@@ -25,7 +27,7 @@
#ifndef _GDL_SWITCHER_H_
#define _GDL_SWITCHER_H_
-#include <gtk/gtknotebook.h>
+#include <gtk/gtk.h>
G_BEGIN_DECLS
@@ -39,14 +41,6 @@ typedef struct _GdlSwitcher GdlSwitcher;
typedef struct _GdlSwitcherPrivate GdlSwitcherPrivate;
typedef struct _GdlSwitcherClass GdlSwitcherClass;
-typedef enum {
- GDL_SWITCHER_STYLE_TEXT,
- GDL_SWITCHER_STYLE_ICON,
- GDL_SWITCHER_STYLE_BOTH,
- GDL_SWITCHER_STYLE_TOOLBAR,
- GDL_SWITCHER_STYLE_TABS
-} GdlSwitcherStyle;
-
struct _GdlSwitcher {
GtkNotebook parent;
diff --git a/src/libgdl/gdl-tools.h b/src/libgdl/gdl-tools.h
deleted file mode 100644
index 32c2e4a41..000000000
--- a/src/libgdl/gdl-tools.h
+++ /dev/null
@@ -1,184 +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/gtkwidget.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) \
-{ \
- 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 \
- }; \
- 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-stock.h b/src/libgdl/gdl.h
index cb6f7abb9..235c5e3eb 100644
--- a/src/libgdl/gdl-stock.h
+++ b/src/libgdl/gdl.h
@@ -1,8 +1,8 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- * gdl-stock.h
- *
- * Copyright (C) 2003 Jeroen Zwartepoorte
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
+ * This file is part of the GNOME Devtools 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
@@ -19,19 +19,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __GDL_STOCK_H__
-#define __GDL_STOCK_H__
-
-#include <glib/gmacros.h> // G_BEGIN_DECLS
-
-G_BEGIN_DECLS
-
-#define GDL_STOCK_CLOSE "gdl-close"
-#define GDL_STOCK_MENU_LEFT "gdl-menu-left"
-#define GDL_STOCK_MENU_RIGHT "gdl-menu-right"
-
-void gdl_stock_init (void);
+#ifndef __GDL_H__
+#define __GDL_H__
-G_END_DECLS
+#include "libgdl/gdl-dock-object.h"
+#include "libgdl/gdl-dock-master.h"
+#include "libgdl/gdl-dock.h"
+#include "libgdl/gdl-dock-item.h"
+#include "libgdl/gdl-dock-item-grip.h"
+#include "libgdl/gdl-dock-bar.h"
-#endif /* __GDL_STOCK_H__ */
+#endif
diff --git a/src/libgdl/libgdl.h b/src/libgdl/libgdl.h
deleted file mode 100644
index 5ee84e1ae..000000000
--- a/src/libgdl/libgdl.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * This file is part of the GNOME Devtools Libraries.
- *
- * Copyright (C) 1999-2000 Dave Camp <dave@helixcode.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#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"
-#include "libgdl/gdl-dock-item.h"
-#include "libgdl/gdl-dock-paned.h"
-#include "libgdl/gdl-dock-notebook.h"
-#include "libgdl/gdl-dock-tablabel.h"
-#include "libgdl/gdl-dock-bar.h"
-#include "libgdl/gdl-switcher.h"
-
-#endif
diff --git a/src/libgdl/libgdltypebuiltins.h b/src/libgdl/libgdltypebuiltins.h
index 8be5decb1..f5e6ea17b 100644
--- a/src/libgdl/libgdltypebuiltins.h
+++ b/src/libgdl/libgdltypebuiltins.h
@@ -4,7 +4,7 @@
#ifndef __LIBGDLTYPEBUILTINS_H__
#define __LIBGDLTYPEBUILTINS_H__ 1
-#include "libgdl/libgdl.h"
+#include "libgdl/gdl.h"
G_BEGIN_DECLS